Bug 1852608 [wpt PR 41826] - Add {{#}} & {{/}} syntax for ChildNodeParts, a=testonly
commitc0ca598e1a637e132b7612a9f962d4e1e6509474
authorMason Freed <masonf@chromium.org>
Wed, 27 Sep 2023 11:56:26 +0000 (27 11:56 +0000)
committermoz-wptsync-bot <wptsync@mozilla.com>
Thu, 28 Sep 2023 14:56:23 +0000 (28 14:56 +0000)
tree0a6cb2f73809871b69edf3fd51ec95ef5b185b5c
parentefa0be085fe91d3d63a511cccf387c4b02828aea
Bug 1852608 [wpt PR 41826] - Add {{#}} & {{/}} syntax for ChildNodeParts, a=testonly

Automatic update from web-platform-tests
Add {{#}} & {{/}} syntax for ChildNodeParts

This CL enables this syntax:

  <span parseparts>
    before {{#}} inside {{/}} after
  </span>

The above snippet will now replace the {{}} parts with empty comment
nodes, and a `ChildNodePart` will be attached that surrounds "inside".

Note the new `parseparts` attribute, which is the opt-in for this
new behavior (in addition to the required runtime flag being enabled
of course).

The implementation looks like this:
 - The `HTMLElementStack` gets a new `parse_parts_count_` which keeps
   a count of the `parseparts` attributes seen on elements. Currently,
   `parseparts` is strictly an opt-in, and subsequent `parseparts`
   can't be used to somehow opt back out.
 - The `HTMLTreeBuilder` relays to the `HTMLTokenizer` whether or not
   we're currently inside a `parseparts` scope.
 - The `HTMLToken` and `AtomicHTMLToken` classes get a new token type,
   `kDOMPart` which is used for the ChildNodePart node endpoint
   markers. These have a DOMPartTokenType which is either
   `kChildNodePartStart` or `kChildNodePartEnd`.
 - The `HTMLTokenizer` looks for `{{#}}` and `{{/}}` in the data
   state, and if detected, switches to two new tokenizer states,
   `kChildNodePartStartState` and `kChildNodePartEndState`. Those both
   immediately emit a `kDOMPart` token and return to the DATA state.
 - The `HTMLTreeBuilder`, when it finds a `kDOMPart` token, forwards
   it to `HTMLConstructionSite::InsertDOMPart()`.
 - `HTMLConstructionSite::InsertDOMPart()` adds the ChildNodePart via
   the existing mechanism.

I split the one test file into multiple, and basically copy/pasted
the "old" declarative style into a new test. Eventually/soon I will
delete the old style (e.g. `<?child-node-part?>`) syntax support, and
the old test with it.

NodeParts aren't yet supported.

Bug: 1453291
Change-Id: I9496685383575f735d48410a50da5593ed027820
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4844130
Reviewed-by: David Baron <dbaron@chromium.org>
Auto-Submit: Mason Freed <masonf@chromium.org>
Commit-Queue: David Baron <dbaron@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1194954}

--

wpt-commits: 2a7dfe2c61e56614d7dac52149015230f16d536d
wpt-pr: 41826
testing/web-platform/tests/dom/parts/basic-dom-part-declarative-brace-syntax.tentative.html [new file with mode: 0644]
testing/web-platform/tests/dom/parts/basic-dom-part-declarative-pi-syntax.tentative.html [new file with mode: 0644]
testing/web-platform/tests/dom/parts/basic-dom-part-objects.tentative.html
testing/web-platform/tests/dom/parts/dom-parts-parseparts-on-body.tentative.html [new file with mode: 0644]
testing/web-platform/tests/dom/parts/dom-parts-parseparts-on-head.tentative.html [new file with mode: 0644]
testing/web-platform/tests/dom/parts/dom-parts-parseparts-on-root.tentative.html [new file with mode: 0644]
testing/web-platform/tests/dom/parts/resources/domparts-utils.js [new file with mode: 0644]