Chrome 63使用输入类型的密码和非唯一的ID引发[DOM]错误 [英] chrome 63 throws [DOM] error with input type password and non-unique ids

查看:1637
本文介绍了Chrome 63使用输入类型的密码和非唯一的ID引发[DOM]错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Chrome 63中,出现以下错误:

[DOM]找到2个非唯一ID的元素#a:



https://jsfiddle.net/arnabgh/jz186qxe/

 < input type =password> 
< input id =a>
< input id =a>

从Chrome 63开始使用输入类型密码时是否有任何特殊验证发生?

解决方案

那么,如果你看看其他的错误信息(我不知道为什么人们会继续阅读和引用错误信息的部分内容而不是整个事情),似乎Chromium团队已经把一个设计文件,专门用于密码表单。我认为,由于密码表单往往会传输敏感信息(即密码),因此任何错误以密码形式应立即引起开发者的注意。设计文档本身甚至重新声明了唯一的ID规则:


Web浏览器的设计符合HTML规范,并且违背它可能会导致您的网页出现意外问题。这意味着:

元素 id 属性应该是唯一的:没有两个元素应该具有相同的 id


(为什么这个规则是唯一有人猜测的;就像他们打算在未来增加更多的东西一样,但是他们会用这条规则发布一个文档并称它为好,这仍然很奇怪。)



似乎并不是禁用此消息的一种方式,但由于它不会阻止页面工作,如果您无法自己更正非唯一ID,唯一的选择似乎是忽略它。


From Chrome 63, following error is thrown :

[DOM] Found 2 elements with non-unique id #a:

https://jsfiddle.net/arnabgh/jz186qxe/

<input type="password">
<input id="a">
<input id="a">

Is there any special validation happening when input type password is used,starting from Chrome 63 ?

解决方案

Well if you look at the rest of the error message (I don't know why people keep reading and quoting only parts of error messages and not the whole thing), it seems the Chromium team has put together a design document that's dedicated to passworded forms.

My guess is that since passworded forms tend to transmit sensitive information (namely, a password), any errors in passworded forms should be brought to the developer's attention immediately. The design document itself even re-states the unique ID rule:

Web browsers are designed with the HTML specification in mind, and going against it can lead to unexpected issues with your web page. This means:

Element id attributes should be unique: no two elements should have the same id.

(Why that rule is the only one that's there is anyone's guess; it certainly looks like they intend to add more in the future, but it's still strange that they'd put out a document with just this one rule and call it good.)

There does not appear to be a way to disable this message, but since it doesn't prevent the page from working, if you're unable to correct the non-unique IDs yourself the only option seems to be to ignore it.

这篇关于Chrome 63使用输入类型的密码和非唯一的ID引发[DOM]错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆