Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<html>
<body>
<div id="container" lang="zh"><span></span></div>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(() => {
let target = container.querySelector('span');
assert_true(target.matches(":lang(zh)"));
target.parentNode.remove();
assert_true(target.matches(":lang(zh)"));
const anotherContainer = document.createElement('div');
anotherContainer.innerHTML = '<div lang="fr"><span></span></div>';
target = anotherContainer.querySelector('span');
assert_true(target.matches(":lang(fr)"));
document.body.append(target.parentNode);
assert_true(target.matches(":lang(fr)"));
}, ":lang pseudo class should work in a disconnected subtree");
</script>
</body>
</html>