Closed
Bug 1473629
Opened 7 years ago
Closed 7 years ago
document.getElementsByName在IE(11、10、9)、Edge中返回的是HTMLCollection不是NodeList
Categories
(Developer Documentation Graveyard :: API: DOM, enhancement)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: 1227839175, Assigned: cmills, NeedInfo)
References
Details
(Whiteboard: [specification][type:bug])
What did you do?
================
1.document.getElementsByName在IE(11、10、9)、Edge中返回的是HTMLCollection不是NodeList!!!我在2018年7月6号测试时发现这个问题!!!测试的Edge浏览器版本信息是Microsoft Edge 42.17134.1.0、Microsoft EdgeHTML 17.17134。并且,IE8以及以下的版本返回的是Object。
在IE和Opera中,getElementsByName()方法已经不会返回那些id为指定值的元素!!!不会返回那些id为指定值的元素!!!不会返回那些id为指定值的元素!!!
What happened?
==============
document.getElementsByName在IE(11、10、9)、Edge中返回的是HTMLCollection不是NodeList!!!我在2018年7月6号测试时发现这个问题!!!测试的Edge浏览器版本信息是Microsoft Edge 42.17134.1.0、Microsoft EdgeHTML 17.17134。并且,IE8以及以下的版本返回的是Object。
在IE和Opera中,getElementsByName()方法已经不会返回那些id为指定值的元素!!!不会返回那些id为指定值的元素!!!不会返回那些id为指定值的元素!!!
What should have happened?
==========================
document.getElementsByName在IE(11、10、9)、Edge中返回的是HTMLCollection不是NodeList!!!我在2018年7月6号测试时发现这个问题!!!测试的Edge浏览器版本信息是Microsoft Edge 42.17134.1.0、Microsoft EdgeHTML 17.17134。并且,IE8以及以下的版本返回的是Object。
在IE和Opera中,getElementsByName()方法已经不会返回那些id为指定值的元素!!!不会返回那些id为指定值的元素!!!不会返回那些id为指定值的元素!!!
Is there anything else we should know?
======================================
document.getElementsByName在IE(11、10、9)、Edge中返回的是HTMLCollection不是NodeList!!!我在2018年7月6号测试时发现这个问题!!!测试的Edge浏览器版本信息是Microsoft Edge 42.17134.1.0、Microsoft EdgeHTML 17.17134。并且,IE8以及以下的版本返回的是Object。
在IE和Opera中,getElementsByName()方法已经不会返回那些id为指定值的元素!!!不会返回那些id为指定值的元素!!!不会返回那些id为指定值的元素!!!
Comment 1•7 years ago
|
||
Google Translate detects this as Chinese, and gives:
document.getElementsByName returns in IE (11, 10, 9), Edge is HTMLCollection is not a NodeList! ! ! I found this problem when I tested it on July 6th, 2018! ! ! The Edge browser version information tested was Microsoft Edge 42.17134.1.0, Microsoft EdgeHTML 17.17134. Also, IE8 and the following versions return Object.
In IE and Opera, the getElementsByName() method will not return those elements whose id is the specified value! ! ! Will not return those elements whose id is the specified value! ! ! Will not return those elements whose id is the specified value! ! !
---
The English version contains this warning:
The getElementsByName method works differently in different browsers. In IE & Opera, getElementsByName() method will also return elements that have an id attribute with the specified value. so you should be careful not to use the same string as both a name and an ID.
Something may have been lost in translation (name vs id), or maybe IE has changed the function to no longer return elements with a matching ID.
1227839175, do you have a URL to demonstrate the issue?
Component: General → API: DOM
Flags: needinfo?(1227839175)
Product: developer.mozilla.org → Developer Documentation
Reporter | ||
Comment 2•7 years ago
|
||
(In reply to John Whitlock [:jwhitlock] from comment #1)
> Google Translate detects this as Chinese, and gives:
>
> document.getElementsByName returns in IE (11, 10, 9), Edge is HTMLCollection
> is not a NodeList! ! ! I found this problem when I tested it on July 6th,
> 2018! ! ! The Edge browser version information tested was Microsoft Edge
> 42.17134.1.0, Microsoft EdgeHTML 17.17134. Also, IE8 and the following
> versions return Object.
> In IE and Opera, the getElementsByName() method will not return those
> elements whose id is the specified value! ! ! Will not return those elements
> whose id is the specified value! ! ! Will not return those elements whose id
> is the specified value! ! !
>
> ---
> The English version contains this warning:
>
> The getElementsByName method works differently in different browsers. In IE
> & Opera, getElementsByName() method will also return elements that have an
> id attribute with the specified value. so you should be careful not to use
> the same string as both a name and an ID.
>
> Something may have been lost in translation (name vs id), or maybe IE has
> changed the function to no longer return elements with a matching ID.
>
> 1227839175, do you have a URL to demonstrate the issue?
Sorry, we can not provide you with a URL to see and verify.At least not now.
It is estimated that it will be available at around 12 noon on July 10, 2018.
but,I wrote the following test code in HTML:
<input id='n1' type='text' />
<input id='n2' type='text' name='n1' />
script code:
console.dir(document.getElementsByName('n1'));
Then,At IE11 and Edge,Output HTMLCollection,Not output NodeList.
Flags: needinfo?(1227839175)
Assignee | ||
Comment 4•7 years ago
|
||
I have tested this, and the reporter is right — Edge/IE return an HTMLCollection, not a NodeList as it says in the spec.
I have updated the English version of the page with a warning note to make this clear, and also submitted a PR to add a note to the relevant browser compat data.
https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByName#Notes
https://github.com/mdn/browser-compat-data/pull/2492
I'd appreciate some help updating the Chinese page. Thanks!
Assignee: nobody → cmills
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Reporter | ||
Comment 5•7 years ago
|
||
Thank you for your adoption!!!
The English version has been updated, and now we are waiting to update the Chinese version and other languages.
Flags: needinfo?(1227839175)
Assignee | ||
Comment 6•7 years ago
|
||
I am closing this one for now, so that our part comes up as done in our tracking.
Assignee | ||
Comment 7•7 years ago
|
||
Ah, I already did ;-)
You need to log in
before you can comment on or make changes to this bug.
Description
•