-
-
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.
Adds the CDATASection class and document.createCDATASection. Fixes #1642.
- Loading branch information
Showing
13 changed files
with
117 additions
and
3 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
"use strict"; | ||
|
||
const TextImpl = require("./Text-impl").implementation; | ||
const NODE_TYPE = require("../node-type"); | ||
|
||
class CDATASectionImpl extends TextImpl { | ||
constructor(args, privateData) { | ||
super(args, privateData); | ||
|
||
this.nodeType = NODE_TYPE.CDATA_SECTION_NODE; | ||
} | ||
} | ||
|
||
module.exports = { | ||
implementation: CDATASectionImpl | ||
}; |
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,3 @@ | ||
[Exposed=Window] | ||
interface CDATASection : Text { | ||
}; |
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
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
14 changes: 14 additions & 0 deletions
14
test/web-platform-tests/to-upstream/dom/nodes/Document-createCDATASection.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,14 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>document.createCDATASection must throw in HTML documents</title> | ||
<link rel="help" href="https://dom.spec.whatwg.org/#dom-document-createcdatasection"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
|
||
<script> | ||
"use strict"; | ||
|
||
assert_throws("NotSupportedError", () => document.createCDATASection("foo")); | ||
|
||
done(); | ||
</script> |
22 changes: 22 additions & 0 deletions
22
test/web-platform-tests/to-upstream/dom/nodes/Document-createCDATASection.xhtml
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,22 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<html xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<meta charset="utf-8"/> | ||
<title>document.createCDATASection</title> | ||
<link rel="help" href="https://dom.spec.whatwg.org/#dom-document-createcdatasection"/> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="Document-createComment-createTextNode.js"></script> | ||
</head> | ||
|
||
<body> | ||
<script> | ||
"use strict"; | ||
test_create("createCDATASection", CDATASection, 4, "#cdata-section"); | ||
|
||
test(() => { | ||
assert_throws("InvalidCharacterError", () => document.createCDATASection(" ]]> ")); | ||
}, "Creating a CDATA section containing the string \"]]>\" must throw"); | ||
</script> | ||
</body> | ||
</html> |
22 changes: 22 additions & 0 deletions
22
test/web-platform-tests/to-upstream/dom/nodes/Document-createComment-createTextNode.js
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,22 @@ | ||
function test_create(method, iface, nodeType, nodeName) { | ||
["\u000b", "a -- b", "a-", "-b", null, undefined].forEach(function(value) { | ||
test(function() { | ||
var c = document[method](value); | ||
var expected = String(value); | ||
assert_true(c instanceof iface); | ||
assert_true(c instanceof CharacterData); | ||
assert_true(c instanceof Node); | ||
assert_equals(c.ownerDocument, document); | ||
assert_equals(c.data, expected, "data"); | ||
assert_equals(c.nodeValue, expected, "nodeValue"); | ||
assert_equals(c.textContent, expected, "textContent"); | ||
assert_equals(c.length, expected.length); | ||
assert_equals(c.nodeType, nodeType); | ||
assert_equals(c.nodeName, nodeName); | ||
assert_equals(c.hasChildNodes(), false); | ||
assert_equals(c.childNodes.length, 0); | ||
assert_equals(c.firstChild, null); | ||
assert_equals(c.lastChild, null); | ||
}, method + "(" + format_value(value) + ")"); | ||
}); | ||
} |