RESOLVED FIXED 144429
LiveNodeList may unexpectedly return an element for empty string
https://bugs.webkit.org/show_bug.cgi?id=144429
Summary LiveNodeList may unexpectedly return an element for empty string
Joseph Pecoraro
Reported 2015-04-29 19:08:45 PDT
* SUMMARY LiveNodeList may unexpectedly return an element for empty string. * TEST <body> <script> var container = document.createElement("div"); var div = document.createElement("div"); div.id = ""; container.appendChild(div); var div2 = document.createElement("div"); div2.id = "foo"; container.appendChild(div2); var list = container.getElementsByTagName("div"); alert(list[""]); // expected: undefined, actual: div#foo alert(list["foo"]); // expected: div#foo, actual: div#foo </script> * NOTES - Firefox and Chrome both produce the expected results.
Attachments
[PATCH] Proposed Fix (3.56 KB, patch)
2015-04-29 19:38 PDT, Joseph Pecoraro
darin: review+
Joseph Pecoraro
Comment 1 2015-04-29 19:38:21 PDT
Created attachment 252029 [details] [PATCH] Proposed Fix
Darin Adler
Comment 2 2015-04-29 19:41:52 PDT
Comment on attachment 252029 [details] [PATCH] Proposed Fix View in context: https://bugs.webkit.org/attachment.cgi?id=252029&action=review > Source/WebCore/dom/LiveNodeList.cpp:57 > + if (elementId.isEmpty()) > + return nullptr; You could put this check after the rootNode.inDocument() block; no need to do even this small amount of extra work in the common case.
Joseph Pecoraro
Comment 3 2015-04-29 20:29:44 PDT
Note You need to log in before you can comment on or make changes to this bug.