Skip to content

Positional HTML methods - #12753

Open
noamr wants to merge 6 commits into
noamr/cpofrom
noamr/positional-html
Open

Positional HTML methods#12753
noamr wants to merge 6 commits into
noamr/cpofrom
noamr/positional-html

Conversation

@noamr

@noamr noamr commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Add appendHTML, prependHTML, beforeHTML, afterHTML, and replaceWithHTML, alongside their *Unsafe variants.

Use 3 helper algorithms for HTML insertion (pre-insert/replace/set), and call those from the appropriate web-exposed method.

ChildNode methods fail silently when the child has no parent, like their equivalent DOM methods,
and fails with a HierarchyRequestError for an invalid parent. Note that a direct child of a template element is considered an invalid parent, as setting HTML to template elements would affect its content rather than its children.

Renamed "set and filter HTML" to "filter and set HTML" to be more consistent with the order of operations and with the newly added helper methods.

Closes #10122


/dynamic-markup-insertion.html ( diff )
/infrastructure.html ( diff )
/system-state.html ( diff )

@noamr noamr closed this Aug 4, 2026
@noamr noamr reopened this Aug 4, 2026
@noamr noamr mentioned this pull request Aug 5, 2026
6 tasks
@noamr
noamr force-pushed the noamr/positional-html branch 2 times, most recently from ee46eb1 to b48a945 Compare August 6, 2026 10:40
Comment thread source Outdated
Comment thread source Outdated
@noamr
noamr force-pushed the noamr/positional-html branch from f9a87e5 to d256495 Compare August 12, 2026 13:25
@zcorpan zcorpan closed this Aug 13, 2026
@zcorpan zcorpan reopened this Aug 13, 2026

@zcorpan zcorpan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM % typo

Comment thread source Outdated
@noamr

noamr commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

Fixes from Opus review:

Blockers

  • Trusted Types sink names: Updated sink names to use the declaring interface ("ChildNode beforeHTMLUnsafe", "ChildNode afterHTMLUnsafe", and "ChildNode replaceWithHTMLUnsafe" instead of "Node ...").

Suggestions

  • DOM divergence note: Added an explicit non-normative <p class="note"> under parent for HTML insertion explaining the intentional divergence from DOM before()/after()/replaceWith() regarding template and Document parents.
  • domintro error descriptions: Updated the domintro entries for all six positional methods to explicitly mention throwing HierarchyRequestError if the parent is a Document or template element.
  • Helper invocation phrasing: Standardized algorithm step invocations across all call sites to use "the parent for HTML insertion given this" and "the HTML insertion target given target".
  • Method alignment: Aligned the step structure of replaceWithHTML and replaceWithHTMLUnsafe (binds parent, returns early if null, then invokes filter and replace with HTML).
  • [Unscopable]: Omission of [Unscopable] for the new ChildNode methods follows standard Web IDL practice (retained only for legacy identifiers for compat).

Nits

  • Helper parameter signatures: Standardized to a string <var>html</var> and data-x="tt-trustedparseroptions" across filter and set HTML, filter and pre-insert HTML, and filter and replace with HTML.
  • Formatting & Whitespace: Fixed indentation (3 spaces) and line wrapping in parent for HTML insertion, closed missing </p> tags on method steps are:</p>, removed double spacing in algorithm signatures, and removed the stray extra blank line before the Document.parseHTML domintro.

@noamr
noamr force-pushed the noamr/positional-html branch 3 times, most recently from dec53b2 to 73e73db Compare August 24, 2026 12:41
@noamr
noamr force-pushed the noamr/positional-html branch from 73e73db to 0c5b590 Compare August 25, 2026 08:18
@noamr
noamr force-pushed the noamr/positional-html branch from 0c5b590 to b21b5d3 Compare August 25, 2026 14:38
@noamr
noamr force-pushed the noamr/positional-html branch 2 times, most recently from d7c9a5e to f23f3cf Compare August 26, 2026 15:13
@noamr
noamr force-pushed the noamr/positional-html branch from f23f3cf to ee138bf Compare August 26, 2026 19:48
@noamr
noamr force-pushed the noamr/positional-html branch from ee138bf to 98ce634 Compare August 28, 2026 12:34
@noamr noamr closed this Aug 28, 2026
@noamr noamr reopened this Aug 28, 2026
Comment thread source Outdated
Comment thread source Outdated
Comment thread source
@zcorpan zcorpan mentioned this pull request Aug 31, 2026
5 tasks
@noamr
noamr force-pushed the noamr/positional-html branch from 98ce634 to c5acf55 Compare September 1, 2026 15:11
@noamr
noamr force-pushed the noamr/positional-html branch from 50d9679 to 8189f57 Compare September 1, 2026 20:38
@noamr
noamr force-pushed the noamr/positional-html branch 3 times, most recently from fd51016 to 4bb4e15 Compare September 3, 2026 20:52
@noamr
noamr force-pushed the noamr/positional-html branch from 4bb4e15 to c74d16b Compare September 4, 2026 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Improve API of insertAdjacent*() methods

2 participants