diff options
author | Andreas Kling <kling@serenityos.org> | 2020-03-29 22:24:23 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-03-30 11:35:39 +0200 |
commit | 0f7bcd4111bae9ae5e4e32c6c013511f89b255f6 (patch) | |
tree | dbe7de82c44bd2b6db4922647290f2339b41c684 /Base/home | |
parent | c56acba75e9fcf6a511e92855f4f4e2221241835 (diff) | |
download | serenity-0f7bcd4111bae9ae5e4e32c6c013511f89b255f6.zip |
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.
Diffstat (limited to 'Base/home')
-rw-r--r-- | Base/home/anon/www/qsa.html | 29 | ||||
-rw-r--r-- | Base/home/anon/www/welcome.html | 1 |
2 files changed, 30 insertions, 0 deletions
diff --git a/Base/home/anon/www/qsa.html b/Base/home/anon/www/qsa.html new file mode 100644 index 0000000000..a0df99c14a --- /dev/null +++ b/Base/home/anon/www/qsa.html @@ -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> diff --git a/Base/home/anon/www/welcome.html b/Base/home/anon/www/welcome.html index af8dd8381d..01a80d67f7 100644 --- a/Base/home/anon/www/welcome.html +++ b/Base/home/anon/www/welcome.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> |