1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:18:13 +00:00

LibWeb: Add naive support for document.querySelectorAll()

This currently returns a JS::Array of elements matching a selector.
The more correct behavior would be to return a static NodeList, but as
we don't have NodeLists right now, that'll be a task for the future.
This commit is contained in:
Andreas Kling 2020-03-29 22:24:23 +02:00
parent c56acba75e
commit 0f7bcd4111
11 changed files with 182 additions and 78 deletions

View file

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div id="foo1" class="foo"></div>
<div id="foo2" class="foo"></div>
<div id="foo3" class="foo"></div>
<pre id="out"></pre>
<script>
var elements = document.querySelectorAll(".foo");
try {
if (elements.length !== 3)
throw 1;
if (elements[0].id !== "foo1")
throw 2;
if (elements[1].id !== "foo2")
throw 3;
if (elements[2].id !== "foo3")
throw 4;
document.getElementById('out').innerHTML = "Success!";
} catch (e) {
document.getElementById('out').innerHTML = "Error number " + e;
}
</script>
</body>
</html>

View file

@ -23,6 +23,7 @@ h1 {
<p>This is a very simple browser built on the LibWeb engine.</p>
<p>Some small test pages:</p>
<ul>
<li><a href="qsa.html">querySelectorAll test</a></li>
<li><a href="innerHTML.html">innerHTML property test</a></li>
<li><a href="position-absolute-top-left.html">position: absolute; for top and left</a></li>
<li><a href="demo.html">fun demo</a></li>