mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:57:44 +00:00
LibWeb: Support more advanced selectors in document.querySelectorAll()
I made some mistakes in the selector parsing code. It's now able to parse selectors composed of multiple complex selectors, instead of just one complex selector.
This commit is contained in:
parent
c1c56b1131
commit
06aec9667e
4 changed files with 21 additions and 17 deletions
|
@ -4,20 +4,20 @@
|
|||
</head>
|
||||
<body>
|
||||
<div id="foo1" class="foo"></div>
|
||||
<code>
|
||||
<div id="foo2" class="foo"></div>
|
||||
<div id="foo3" class="foo"></div>
|
||||
</code>
|
||||
<pre id="out"></pre>
|
||||
<script>
|
||||
var elements = document.querySelectorAll(".foo");
|
||||
var elements = document.querySelectorAll("code .foo");
|
||||
|
||||
try {
|
||||
if (elements.length !== 3)
|
||||
if (elements.length !== 2)
|
||||
throw 1;
|
||||
if (elements[0].id !== "foo1")
|
||||
throw 2;
|
||||
if (elements[1].id !== "foo2")
|
||||
if (elements[0].id !== "foo2")
|
||||
throw 3;
|
||||
if (elements[2].id !== "foo3")
|
||||
if (elements[1].id !== "foo3")
|
||||
throw 4;
|
||||
document.getElementById('out').innerHTML = "Success!";
|
||||
} catch (e) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue