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:
parent
c56acba75e
commit
0f7bcd4111
11 changed files with 182 additions and 78 deletions
29
Base/home/anon/www/qsa.html
Normal file
29
Base/home/anon/www/qsa.html
Normal 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>
|
|
@ -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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue