Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /html/dom/elements/global-attributes/the-anchor-attribute-xml.tentative.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<link rel=author href="mailto:jarhar@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<script>
test(() => {
const xmlDoc = document.implementation.createDocument(null, 'root', null);
assert_equals(xmlDoc.contentType, 'application/xml');
const innerDoc = xmlDoc.documentElement;
const html = '<div id="target">target</div><div anchor="target">anchored</div>';
innerDoc.innerHTML = html;
assert_equals(innerDoc.innerHTML, html);
const target = innerDoc.children[0];
const anchored = innerDoc.children[1];
assert_equals(anchored.anchorElement, target, 'Setting the anchor attribute in XML should work.');
anchored.anchorElement = target;
assert_equals(anchored.anchorElement, target, 'Setting element.anchorElement in an XML document should work.');
});
</script>