Skip to content

Commit

Permalink
Add declarative DOM Parts syntax
Browse files Browse the repository at this point in the history
This CL adds the ability to construct DOM Parts during document
parsing via "fake" processing instructions:

<section>
  <h1 id="name">
    <?child-node-part?> <?/child-node-part?>
  </h1>
  Email: <?node-part metadata?><a id="link"></a>
</section>

In this example, <?child-node-part?><?/child-node-part?> will
be left in the document, but a ChildNodePart will also be constructed
with previous/next endpoints of those two comment nodes. And the
<?node-part> will be left in place, but a NodePart will be attached
to the <a> element.

Note that <?foo?> is exactly equivalent to <!--?foo?-->, and both
are tested in the new WPT.

This CL also:
 - adds a virtual test suite that makes sure no functionality breaks
   or leaks when DOMPartAPI is disabled.
 - revamps the WPT, adding a `assertEqualParts()` that checks a given
   parts list via the type of parts and the metadata. This is then
   used everywhere.
 - add testing of declarative DOM Parts for three cases:
   1. main document parsing (passes with this CL)
   2. template parsing (doesn't yet pass)
   3. cloned templates (not even sure if this should ever pass)

Bug: 1453291,1465062
Change-Id: I2eaef72a21fc2deaa251deb0731b5ff55ef19d8c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4686189
Reviewed-by: David Baron <dbaron@chromium.org>
Auto-Submit: Mason Freed <masonf@chromium.org>
Commit-Queue: Stefan Zager <szager@chromium.org>
Reviewed-by: Stefan Zager <szager@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1170849}
  • Loading branch information
mfreed7 authored and chromium-wpt-export-bot committed Jul 15, 2023
1 parent 404414b commit eeab1cb
Showing 1 changed file with 233 additions and 130 deletions.
Loading

0 comments on commit eeab1cb

Please sign in to comment.