Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /dom/nodes/ParentNode-querySelector-nested-nth-child.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>querySelector with nested :nth-child() without tag names</title>
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<main>
<div> <!-- :nth-child(1) of main -->
<div> <!-- :nth-child(1) of div -->
<p>
<a href="#" id="targetLink">link</a>
</p>
</div>
</div>
</main>
<script>
"use strict";
test(() => {
const selector = "main > :nth-child(1) > :nth-child(1) a";
const expectedLink = document.getElementById("targetLink");
assert_equals(document.querySelector(selector), expectedLink);
});
</script>