浏览代码

fix: work around IE/Edge bug when accessing document.activeElement from iframe

close #6157
Evan You 9 年之前
父节点
当前提交
fc3d7cd7a9
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      src/platforms/web/runtime/modules/dom-props.js

+ 5 - 1
src/platforms/web/runtime/modules/dom-props.js

@@ -63,7 +63,11 @@ function shouldUpdateValue (
 function isDirty (elm: acceptValueElm, checkVal: string): boolean {
   // return true when textbox (.number and .trim) loses focus and its value is
   // not equal to the updated value
-  return document.activeElement !== elm && elm.value !== checkVal
+  let notInFocus = true
+  // #6157
+  // work around IE bug when accessing document.activeElement in an iframe
+  try { notInFocus = document.activeElement !== elm } catch (e) {}
+  return notInFocus && elm.value !== checkVal
 }
 
 function isInputChanged (elm: any, newVal: string): boolean {