-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement element.insertAdjacentHTML()
Fixes #1219.
- Loading branch information
1 parent
892c63d
commit ac321fc
Showing
4 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
test/web-platform-tests/to-upstream/domparsing/insert-adjacent.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>element.insertAdjacentHTML error cases</title> | ||
<link rel="help" href="https://w3c.github.io/DOM-Parsing/#widl-Element-insertAdjacentHTML-void-DOMString-position-DOMString-text"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<div id="element"></div> | ||
|
||
<script> | ||
"use strict"; | ||
|
||
test(() => { | ||
const el = document.querySelector("#element"); | ||
|
||
assert_throws("SYNTAX_ERR", () => { | ||
el.insertAdjacentHTML("invalid", "test"); | ||
}); | ||
}, "Throws when given an invalid position"); | ||
|
||
test(() => { | ||
// A detached element does not have a parent node. | ||
const el = document.createElement("span"); | ||
|
||
assert_throws("NO_MODIFICATION_ALLOWED_ERR", () => { | ||
el.insertAdjacentHTML("beforebegin", "test"); | ||
}); | ||
}, "Throws when inserting into an element whose parent is null"); | ||
|
||
test(() => { | ||
// The parent node of the html element is a document. | ||
const el = document.querySelector("html"); | ||
|
||
assert_throws("NO_MODIFICATION_ALLOWED_ERR", () => { | ||
el.insertAdjacentHTML("beforebegin", "test"); | ||
}); | ||
}, "Throws when inserting into an element whose parent is a document"); | ||
</script> |