Bug 1857113 [wpt PR 42352] - Enable declarative DOM Parts within template innerHTML...
commit54fbdc7fd1905d70e7aee02ebad8739658a2fdae
authorMason Freed <masonf@chromium.org>
Wed, 18 Oct 2023 08:37:35 +0000 (18 08:37 +0000)
committermoz-wptsync-bot <wptsync@mozilla.com>
Thu, 26 Oct 2023 08:55:55 +0000 (26 08:55 +0000)
tree2b87cd25af3987a69cd45eb3ef0b348a2496d191
parent105ae523c32e0b081cc024e37a4358ebab2f93a3
Bug 1857113 [wpt PR 42352] - Enable declarative DOM Parts within template innerHTML setting, a=testonly

Automatic update from web-platform-tests
Enable declarative DOM Parts within template innerHTML setting

This CL allows this snippet to work:

  const wrapper = document.createElement('template');
  wrapper.parseparts = true;
  wrapper.innerHTML = '<h1>{{#}}content{{/}}</h1>';
  wrapper.content.getPartRoot().getParts === 1;

To achieve this, several things had to change:
 - Element::SetInnerHTMLInternal() has to detect that the context
   element is a `<template>` with the `parseparts` attribute, and
   swap the parts list from the parser-created document fragment
   over to the template's content document fragment.
 - The HTMLElementStack's code to check for `parseparts` needs to
   check a new state enum, which allows:
    1. always parsing parts - used for innerHTML on `<template
       parseparts>`,
    2. never parsing parts - used on any other innerHTML, or
    3. watching for the parseparts attribute within content - used
       for main document parsing
 - HTMLDocumentParser::ParseDocumentFragment() needs to also detect
   the `<template parseparts>` context element, and forward that
   bit over to the HTMLElementStack, via HTMLTreeBuilder and
   HTMLConstructionSite.
 - The HTMLDocumentParserFastPath needs to be updated to notice
   the `<template parseparts>` and bail (at least for now).

Bug: 1453291
Change-Id: I3eadba790b6bb197ed7a55017a14e3af942de519
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4914333
Commit-Queue: Mason Freed <masonf@chromium.org>
Auto-Submit: Mason Freed <masonf@chromium.org>
Reviewed-by: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1205926}

--

wpt-commits: 5cdb13a85ebc46aca9d65ceff121acd99db502c7
wpt-pr: 42352
testing/web-platform/tests/dom/parts/basic-dom-part-declarative-brace-syntax-innerhtml.tentative.html [new file with mode: 0644]