Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /domparsing/svg-template.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>SVG-namespace template elements are treated as expected</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
"use strict";
test(() => {
const p = new DOMParser();
const doc = p.parseFromString("<!DOCTYPE html><svg><template>text</template></svg>", "text/html");
const template = doc.querySelector("template");
assert_equals(template.textContent, "text");
assert_false("content" in template);
}, "document");
test(() => {
const doc = document.implementation.createHTMLDocument();
doc.body.innerHTML = "<svg><template></template></svg>";
doc.querySelector("template").innerHTML = "text";
const template = doc.querySelector("template");
assert_equals(template.textContent, "text");
assert_false("content" in template);
}, "fragment");
</script>