Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
554 views
in Technique[技术] by (71.8m points)

html - Chrome 63+ throws [DOM] error with input type password and non-unique ids

From Chrome 63, the following error is thrown:

[DOM] Found 2 elements with non-unique id #a: (More info: https://goo.gl/9p2vKq)

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Yes, there is; that's why you're seeing that message. But I suspect that's not what you're really asking.

If your question is why Chrome has started displaying this message, 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. Greater care should be taken when designing and implementing passworded forms.

The document the error message links to (which I cannot assume that you've read since you've made no acknowledgement of it in your question) has a subsection on writing standards-compliant HTML, in which the unique ID rule is re-stated:

Follow HTML guidelines

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 beyond how the duplicate IDs would have (and they don't either), if you're unable to correct the non-unique IDs yourself it's safe to ignore it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...