Skip to content

Commit

Permalink
Add more selector regression tests
Browse files Browse the repository at this point in the history
These were fixed at some point. Closes #1750. Closes #2114. Closes #3015. Closes #3297.
  • Loading branch information
domenic committed May 1, 2023
1 parent f75a9d1 commit 7512ce9
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<title>:not() with multiple selectors in the list</title>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<!-- Regression test for https://github.com/jsdom/jsdom/issues/3297 -->

<div id="container">
<div id="container-inner-1"></div>
<div id="container-inner-2">
<p>Foo</p>
<button>Bar</button>
</div>
</div>

<script>
"use strict";
test(() => {
const container = document.getElementById("container");
assert_equals(container.querySelectorAll(":not(svg, svg *)").length, 4);
});
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<title>svg:not(:root) in a HTML document</title>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<!-- Regression test for https://github.com/jsdom/jsdom/issues/1750 -->

<svg xmlns="http://www.w3.org/2000/svg" width="150" height="100" viewBox="0 0 3 2" id="the-svg">
<rect width="1" height="2" x="0" fill="#008d46" />
<rect width="1" height="2" x="1" fill="#ffffff" />
<rect width="1" height="2" x="2" fill="#d2232c" />
</svg>

<script>
"use strict";
test(() => {
const theSvg = document.getElementById("the-svg");
assert_not_equals(theSvg, null, "precondition check: getElementById works");

assert_equals(document.querySelector("svg:not(:root)"), theSvg);
});
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Element local name with an underscore in querySelector</title>
<meta charset="utf-8"/>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<!-- Regression test for https://github.com/jsdom/jsdom/issues/3015 -->
</head>
<body>
<data><_g><b>hey</b></_g></data>

<script>
/*<![CDATA[*/
"use strict";
test(() => {
assert_equals(document.querySelector("data > _g > b").textContent, "hey");
});
/*]]>*/
</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<title>Selecting a svg element with a class selector</title>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<!-- Regression test for https://github.com/jsdom/jsdom/issues/2114 -->

<div class="test">
</div>
<svg class="test">
</svg>

<script>
"use strict";
test(() => {
assert_equals(document.querySelectorAll("svg.test").length, 1);
});
</script>

0 comments on commit 7512ce9

Please sign in to comment.