Commit b42e8076 authored by rob.buis@samsung.com's avatar rob.buis@samsung.com

getElementsByClassName should include non styled Elements

Allow Elements who are not styled but have class set to be retrieved using getElementsByClassName.

Matches FF behavior.

https://bugs.webkit.org/show_bug.cgi?id=94718

Review URL: https://codereview.chromium.org/458663003

git-svn-id: svn://svn.chromium.org/blink/trunk@180414 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 8d4e7f36
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
<t:x class="a" t:class="a" h:class="a" g:class="a"/> <t:x class="a" t:class="a" h:class="a" g:class="a"/>
<script> <script>
var collection = document.getElementsByClassName("a"), var collection = document.getElementsByClassName("a"),
test = document.getElementsByTagName("x") test = document.getElementsByTagNameNS("*", "x")
t(collection, [test[0], test[1]]) t(collection, [test[0], test[1], test[4]])
</script> </script>
</body> </body>
</html> </html>
This test checks to see if getElementsByClassName finds non styled elements.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS document.getElementsByClassName('target').length is 2
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test.js"></script>
</head>
<body>
<script type="text/javascript">
description("This test checks to see if getElementsByClassName finds non styled elements.");
var d = document.createElement("div");
d.setAttribute("class", "target");
document.documentElement.appendChild(d);
var e = document.createElementNS("http://foo.com", "div");
e.setAttribute("class", "target");
document.documentElement.appendChild(e);
shouldBe("document.getElementsByClassName('target').length", "2");
</script>
</body>
</html>
...@@ -65,10 +65,6 @@ inline bool ClassCollection::elementMatches(const Element& testElement) const ...@@ -65,10 +65,6 @@ inline bool ClassCollection::elementMatches(const Element& testElement) const
return false; return false;
if (!m_classNames.size()) if (!m_classNames.size())
return false; return false;
// FIXME: DOM4 allows getElementsByClassName to return non StyledElement.
// https://bugs.webkit.org/show_bug.cgi?id=94718
if (!testElement.isStyledElement())
return false;
return testElement.classNames().containsAll(m_classNames); return testElement.classNames().containsAll(m_classNames);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment