核心1.5.1在更新到最新的Chrome后,对IE输入类型电子邮件检查引发警告

Ecl*_*tic 5 mootools google-chrome-devtools

自升级到Chrome 41.0.2272.89 m以来,Mootools Core 1.5.1正在发出警告.没什么大不了的,但是如果你像我一样有保障,那可能会让你感到有点不舒服.

var input = document.createElement('input'), volatileInputValue, html5InputSupport;

// #2178
input.value = 't';
input.type = 'submit';
volatileInputValue = input.value != 't';

// #2443 - IE throws "Invalid Argument" when trying to use html5 input types
try {
    input.type = 'email';
    html5InputSupport = input.type == 'email';
} catch(e){}
Run Code Online (Sandbox Code Playgroud)

抛出警告:

指定值"t"不是有效的电子邮件地址.

Ecl*_*tic 6

要修复,请将上面的try catch更改为:

try {
    input.value = '';
    input.type = 'email';
    html5InputSupport = input.type == 'email';
} catch(e){}
Run Code Online (Sandbox Code Playgroud)

或者在压缩版本中,搜索"email"并更改:

try{p.type="email",h="email"==p.type}catch(c){}
Run Code Online (Sandbox Code Playgroud)

至:

try{p.value="",p.type="email",h="email"==p.type}catch(c){}
Run Code Online (Sandbox Code Playgroud)

  • 如上所述,还有一个问题:[Git](https://github.com/lyzzard/mootools-core/commit/9f374e8709358ceffa51375ffa841d083c315120) (3认同)
  • ......今天Arian刚刚合并了.`+ 1` (2认同)