blob: 54ff4ccaec9ff3273013eb357ad10a80da2a7b48 [file] [log] [blame]
Domenic Denicola306b7ef2020-04-07 14:19:161<!DOCTYPE html>
2<meta charset="utf-8">
3<title>Attributes are Nodes but should not be accepted outside of the `attributes` NamedNodeMap</title>
4<link rel=help href="https://dom.spec.whatwg.org/#dom-core-changes">
5<script src="/resources/testharness.js"></script>
6<script src="/resources/testharnessreport.js"></script>
7
8<script>
9"use strict";
10
11test(() => {
12
13 const attribute = document.createAttribute("newattribute");
14
15 assert_true(attribute instanceof Node, "attribute instances are instances of Node");
16 assert_true(Attr.prototype instanceof Node, "attribute instances are instances of Node");
17
18}, "Attrs are subclasses of Nodes");
19
20test(() => {
21
22 const parent = document.createElement("p");
23
24 const attribute = document.createAttribute("newattribute");
25 assert_throws_dom("HierarchyRequestError", () => {
26 parent.appendChild(attribute);
27 });
28
29}, "appendChild with an attribute as the child should fail");
30
31test(() => {
32
33 const parent = document.createElement("p");
34 parent.appendChild(document.createElement("span"));
35
36 const attribute = document.createAttribute("newattribute");
37 assert_throws_dom("HierarchyRequestError", () => {
38 parent.replaceChild(attribute, parent.firstChild);
39 });
40
41}, "replaceChild with an attribute as the child should fail");
42
43test(() => {
44
45 const parent = document.createElement("p");
46 parent.appendChild(document.createElement("span"));
47
48 const attribute = document.createAttribute("newattribute");
49 assert_throws_dom("HierarchyRequestError", () => {
50 parent.insertBefore(attribute, parent.firstChild);
51 });
52
53}, "insertBefore with an attribute as the child should fail");
54
55</script>