Skip to content

Commit

Permalink
Change ChildNodePart comment nodes from "S"/"E" to "#" and "/"
Browse files Browse the repository at this point in the history
This better matches the declarative HTML syntax, which is:

  <div parseparts>{{#}} child nodes {{/}}</div>

No real functional change, since typical usage doesn't examine the
content of these comments.

Bug: 40271855
Change-Id: Id2a4da2ee22b34e04dca2e4adca7bcacb57e5207
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5640573
Auto-Submit: Mason Freed <masonf@chromium.org>
Reviewed-by: Joey Arhar <jarhar@chromium.org>
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1317945}
  • Loading branch information
Mason Freed authored and chromium-wpt-export-bot committed Jun 21, 2024
1 parent 381b84f commit e4bd6a4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
</div>

<script>
const kChildNodePartStartCommentData = "#";
const kChildNodePartEndCommentData = "/";
function assertIsComment(node, commentText) {
assert_true(node instanceof Comment);
// TODO(crbug.com/40271855): While developing alternative syntax, the comment might be empty or it might be "S"/"E".
// TODO(crbug.com/40271855): While developing alternative syntax, the comment might be empty or it might be "#" or "/".
assert_true(node.textContent === '' || node.textContent === commentText);
}

Expand All @@ -41,13 +43,13 @@
let expectedRootParts = [{type:'ChildNodePart',metadata:[]}];
assertEqualParts(root.getParts(),expectedRootParts,0,'declarative root missing parts');
const childPart1 = root.getParts()[0];
assertIsComment(childPart1.previousSibling,'S');
assertIsComment(childPart1.nextSibling,'E');
assertIsComment(childPart1.previousSibling,kChildNodePartStartCommentData);
assertIsComment(childPart1.nextSibling,kChildNodePartEndCommentData);
const expectedChild1Parts = [{type:'ChildNodePart',metadata:[]}];
assertEqualParts(childPart1.getParts(),expectedChild1Parts,0,'First level childpart should just have one child part');
const childPart2 = childPart1.getParts()[0];
assertIsComment(childPart2.previousSibling,'S');
assertIsComment(childPart2.nextSibling,'E');
assertIsComment(childPart2.previousSibling,kChildNodePartStartCommentData);
assertIsComment(childPart2.nextSibling,kChildNodePartEndCommentData);
const expectedChild2Parts = [{type:'NodePart',metadata:[]}];
assertEqualParts(childPart2.getParts(),expectedChild2Parts,0,'Second level childpart should have just the node part');
assert_true(childPart2.getParts()[0].node instanceof HTMLSpanElement);
Expand Down
20 changes: 11 additions & 9 deletions dom/parts/basic-dom-part-declarative-brace-syntax.tentative.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,16 @@ <h1 id="name" parseparts>
function addPartsCleanup(t,partRoot) {
t.add_cleanup(() => partRoot.getParts().forEach(part => part.disconnect()));
}
const kChildNodePartStartCommentData = "#";
const kChildNodePartEndCommentData = "/";
function assertIsComment(node, commentText) {
assert_true(node instanceof Comment);
// TODO(crbug.com/40271855): While developing alternative syntax, the comment might be empty or it might be "#" or "/".
assert_true(node.textContent === '' || node.textContent === commentText);
}

const template = document.getElementById('declarative');
['Main Document','Template','Clone','PartClone'].forEach(testCase => {
function assertIsComment(node, commentText) {
assert_true(node instanceof Comment);
// TODO(crbug.com/40271855): While developing alternative syntax, the comment might be empty or it might be "S"/"E".
assert_true(node.textContent === '' || node.textContent === commentText);
}
test((t) => {
let doc,target,wrapper,cleanup;
let expectDOMParts = true;
Expand Down Expand Up @@ -116,13 +118,13 @@ <h1 id="name" parseparts>
assert_equals(root.getParts()[i].node,target.querySelector(`#nodepart${i}`));
}
const childPart1 = root.getParts()[0];
assertIsComment(childPart1.previousSibling,'S');
assertIsComment(childPart1.nextSibling,'E');
assertIsComment(childPart1.previousSibling,kChildNodePartStartCommentData);
assertIsComment(childPart1.nextSibling,kChildNodePartEndCommentData);
const expectedChild1Parts = [{type:'ChildNodePart',metadata:[]}];
assertEqualParts(childPart1.getParts(),expectedChild1Parts,0,'First level childpart should just have one child part');
const childPart2 = childPart1.getParts()[0];
assertIsComment(childPart2.previousSibling,'S');
assertIsComment(childPart2.nextSibling,'E');
assertIsComment(childPart2.previousSibling,kChildNodePartStartCommentData);
assertIsComment(childPart2.nextSibling,kChildNodePartEndCommentData);
const expectedChild2Parts = [{type:'NodePart',metadata:[]},{type:'AttributePart',metadata:[]}];
assertEqualParts(childPart2.getParts(),expectedChild2Parts,0,'Second level childpart should have NodePart and AttributePart');
assert_true(childPart2.getParts()[0].node instanceof HTMLSpanElement);
Expand Down

0 comments on commit e4bd6a4

Please sign in to comment.