From f1d7f3bb694102dea642ca1ddd9887cb9a1e585f Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Thu, 2 Jul 2026 10:50:23 +0100 Subject: [PATCH 01/12] createParserOptions --- source | 298 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 145 insertions(+), 153 deletions(-) diff --git a/source b/source index 90c6259281b..06e383d5118 100644 --- a/source +++ b/source @@ -4994,6 +4994,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • data
  • TrustedScriptURL
  • get trusted type compliant string
  • +
  • get trusted type compliant input
  • @@ -125730,8 +125731,12 @@ enum DOMParserSupportedType {
  • Let target be this's template contents if this is a template element; otherwise this.

  • -
  • Set and filter HTML given target, html, - options, and true.

  • +
  • Let fragment be the result of invoking the fragment parsing algorithm + steps given target, html, options, and "remove".

  • + +
  • If fragment is non-null, then replace + all with fragment within target.

  • @@ -125741,8 +125746,12 @@ enum DOMParserSupportedType { steps are:

      -
    1. Set and filter HTML given this, html, - options, and true.

    2. +
    3. Let fragment be the result of invoking the fragment parsing algorithm + steps given this, html, options, and "remove".

    4. + +
    5. If fragment is non-null, then replace + all with fragment within this.

    @@ -125752,17 +125761,21 @@ enum DOMParserSupportedType { method steps are:

      -
    1. Let compliantHTML be the result of invoking the get trusted type compliant string algorithm with

      Let (compliantHTML, compliantOptions) be the result of invoking the + get trusted type compliant input algorithm with TrustedHTML, this's relevant global - object, html, "Element setHTMLUnsafe", and "script".

    2. + object, html, options, and "Element + setHTMLUnsafe".

    3. Let target be this's template contents if this is a template element; otherwise this.

    4. -
    5. Set and filter HTML given target, compliantHTML, - options, and false.

    6. +
    7. Let fragment be the result of invoking the fragment parsing algorithm + steps given target, compliantHTML, compliantOptions, and + "keep".

    8. + +
    9. If fragment is non-null, then replace + all with fragment within target.

    @@ -125772,14 +125785,18 @@ enum DOMParserSupportedType { options) method steps are:

      -
    1. Let compliantHTML be the result of invoking the get trusted type compliant string algorithm with

      Let (compliantHTML, compliantOptions) be the result of invoking the + get trusted type compliant input algorithm with TrustedHTML, this's relevant global - object, html, "ShadowRoot setHTMLUnsafe", and "script".

    2. + object, html, options, and "ShadowRoot + setHTMLUnsafe".

      + +
    3. Let fragment be the result of invoking the fragment parsing algorithm + steps given this, compliantHTML, compliantOptions, and + "keep".

    4. -
    5. Set and filter HTML given this, compliantHTML, - options, and false.

    6. +
    7. If fragment is non-null, then replace + all with fragment within this.

    @@ -125823,11 +125840,11 @@ enum DOMParserSupportedType { method steps are:

      -
    1. Let compliantHTML be the result of invoking the get trusted type compliant string algorithm with

      Let (compliantHTML, compliantOptions) be the result of invoking the + get trusted type compliant input algorithm with TrustedHTML, this's relevant global - object, html, "Document parseHTMLUnsafe", and "script".

    2. + object, html, options, and "Document + parseHTMLUnsafe".

    3. Let document be a new Document, whose DOMParserSupportedType { compliantHTML.

    4. Let sanitizer be the result of calling get a sanitizer instance from - options with options and false.

    5. + options with compliantOptions and false.

    6. Call sanitize on document with sanitizer and false.

    7. @@ -125960,21 +125977,66 @@ enum DOMParserSupportedType {

      The fragment parsing algorithm steps, given an Element or - DocumentFragment target, a string markup, and an optional - parser scripting mode scriptingMode (default Inert), are:

      + DocumentFragment target, a string markup, a dictionary + options, and unsafeMarkupHandling, which is one of "remove", "keep", or "legacy", + are:

        -
      1. Assert: scriptingMode is either Inert or Fragment. +

      2. Let context be target if target is an + Element; otherwise target's host.

      3. + +
      4. Assert: context is non-null.

      5. + +
      6. +

        If all of the following are true:

        +
          +
        • unsafeMarkupHandling is "remove";
        • +
        • context's local name is + "script"; and
        • +
        • context's namespace is the + HTML namespace or the SVG namespace,
        • +
        +

        then return null.

        +
      7. + +
      8. Let safe be true if unsafeMarkupHandling is "remove"; otherwise false.

      9. + +
      10. Let sanitizer be the result of calling getting a sanitizer from options given safe.

      11. -
      12. If target's node document is an XML +

      13. Let scriptingMode be Inert.

      14. + +
      15. +

        If options["runScripts"] + is true:

        +
          +
        1. Assert: unsafeMarkupHandling is not "remove".

        2. + +
        3. Set scriptingMode to Fragment.

        4. +
        +
      16. + +
      17. Let allowDeclarativeShadowRoots be false if unsafeMarkupHandling is + "legacy"; otherwise true.

      18. + +
      19. If unsafeMarkupHandling is "legacy" and + target's node document is an XML document, then return the result of invoking the XML fragment parsing algorithm given target and markup.

      20. -
      21. Return the result of the HTML fragment parsing algorithm given - target, markup, false, and scriptingMode.

      22. +
      23. Let fragment be the result of the HTML fragment parsing algorithm + given target, markup, allowDeclarativeShadowRoots, and + scriptingMode.

      24. + +
      25. Sanitize fragment given sanitizer and + safe.

      26. + +
      27. Return fragment.

      @@ -125995,29 +126057,18 @@ enum DOMParserSupportedType { are:

        -
      1. Let compliantString be the result of invoking the get trusted type compliant string algorithm with TrustedHTML, this's relevant global - object, the given value, "Element innerHTML", and "script".

      2. - -
      3. Let target be this.

      4. - -
      5. -

        If target is a template element, then set target to the - template element's template contents (a - DocumentFragment).

        - -

        Setting innerHTML on a - template element will replace all the nodes in its template contents - rather than its children.

        -
      6. +
      7. Let (compliantString, compliantOptions) be the result of invoking + the get trusted type compliant input algorithm with + TrustedHTML, this's relevant global + object, the given value, a new SetHTMLUnsafeOptions dictionary, and "Element innerHTML".

      8. -
      9. Let fragment be the result of invoking the fragment parsing algorithm - steps with target and compliantString.

      10. +
      11. Let fragment be the result of invoking the fragment parsing algorithm + steps given this, compliantString, compliantOptions, + and "legacy".

      12. -
      13. Replace all with fragment - within target.

      14. +
      15. Replace all with fragment within + this.

      @@ -126026,14 +126077,15 @@ enum DOMParserSupportedType { steps are:

        -
      1. Let compliantString be the result of invoking the get trusted type compliant string algorithm with TrustedHTML, this's relevant global - object, the given value, "ShadowRoot innerHTML", and "script".

      2. +
      3. Let (compliantString, compliantOptions) be the result of invoking + the get trusted type compliant input algorithm with + TrustedHTML, this's relevant global + object, the given value, a new SetHTMLUnsafeOptions dictionary, and "ShadowRoot innerHTML".

      4. Let fragment be the result of invoking the fragment parsing algorithm - steps with this and compliantString.

      5. + steps given this, compliantString, compliantOptions, + and "legacy".

      6. Replace all with fragment within this.

      7. @@ -126091,30 +126143,31 @@ enum DOMParserSupportedType { are:

          -
        1. Let compliantString be the result of invoking the get trusted type compliant string algorithm with TrustedHTML, this's relevant global - object, the given value, "Element outerHTML", and "script".

        2. +
        3. Let (compliantString, compliantOptions) be the result of invoking + the get trusted type compliant input algorithm with + TrustedHTML, this's relevant global + object, the given value, a new SetHTMLUnsafeOptions dictionary, and "Element outerHTML".

        4. -
        5. Let parent be this's parent.

        6. +
        7. Let parent be this's parent.

        8. -
        9. If parent is null, return. There would be no way to obtain a - reference to the nodes created even if the remaining steps were run.

        10. +
        11. If parent is null, return. There would be no way to obtain a reference to the + nodes created even if the remaining steps were run.

        12. -
        13. If parent is a Document, throw a - "NoModificationAllowedError" DOMException.

        14. +
        15. If parent is a Document, throw a + "NoModificationAllowedError" DOMException.

        16. -
        17. If parent is a DocumentFragment, set parent to the - result of creating an element given this's - node document, "body", and the HTML - namespace.

        18. +
        19. If parent is a DocumentFragment, set parent to the + result of creating an element given this's + node document, "body", and the HTML + namespace.

        20. -
        21. Let fragment be the result of invoking the fragment parsing algorithm - steps given parent and compliantString.

        22. +
        23. Let fragment be the result of invoking the fragment parsing algorithm + steps given parent, compliantString, compliantOptions, + and "legacy".

        24. -
        25. Replace this with - fragment within this's parent.

        26. +
        27. Replace this with + fragment within this's parent.

        @@ -126168,11 +126221,11 @@ enum DOMParserSupportedType { string)
        method steps are:

          -
        1. Let compliantString be the result of invoking the get trusted type compliant string algorithm with TrustedHTML, this's relevant global - object, string, "Element insertAdjacentHTML", and "script".

        2. +
        3. Let (compliantString, compliantOptions) be the result of invoking + the get trusted type compliant input algorithm with + TrustedHTML, this's relevant global + object, the given value, a new SetHTMLUnsafeOptions dictionary, and "Element insertAdjacentHTML".

        4. Let context be null.

        5. @@ -126215,10 +126268,9 @@ enum DOMParserSupportedType { data-x="">body
          ", and the HTML namespace.

          -
        6. -

          Let fragment be the result of invoking the fragment parsing algorithm - steps with context and compliantString.

          -
        7. +
        8. Let fragment be the result of invoking the fragment parsing algorithm + steps given context, compliantString, compliantOptions, + and "legacy".

        9. Use the first matching item from this list:
          @@ -126294,11 +126346,12 @@ enum DOMParserSupportedType { method steps are:

            -
          1. Let compliantString be the result of invoking the get - trusted type compliant string algorithm with TrustedHTML, this's relevant global - object, string, "Range createContextualFragment", and - "script".

          2. +
          3. Let (compliantString, compliantOptions) be the result of invoking + the get trusted type compliant input algorithm with + TrustedHTML, this's relevant global + object, string, a new SetHTMLUnsafeOptions whose runScripts is true, and "Range createContextualFragment".

          4. Let node be this's start node.

          5. @@ -126330,9 +126383,9 @@ enum DOMParserSupportedType { data-x="">body", and the HTML namespace.

            -
          6. Return the result of invoking the fragment parsing algorithm steps with - element, compliantString, and Fragment.

          7. +
          8. Return the result of invoking the fragment parsing algorithm steps given + element, compliantString, compliantOptions, and "legacy".

          @@ -127697,67 +127750,6 @@ dictionary SanitizerConfig {

          Sanitization algorithms

          -
          -

          To set and filter HTML, given an Element or - DocumentFragment target, a string html, a - dictionary options, and a boolean safe:

          - -
            -
          1. Let context be target if target is an - Element; otherwise target's host.

          2. - -
          3. Assert: context is non-null.

          4. - -
          5. -

            If all of the following are true:

            - -
              -
            • safe;

            • - -
            • context's local name is - "script"; and

            • - -
            • context's namespace is the - HTML namespace or the SVG namespace,

            • -
            - -

            then return.

            -
          6. - -
          7. Let sanitizer be the result of calling getting a sanitizer from options given safe.

          8. - -
          9. Let scriptingMode be Inert.

          10. - -
          11. -

            If options["runScripts"] - is true:

            - -
              -
            1. Assert: safe is false.

            2. - -
            3. Set scriptingMode to Fragment.

              -
            -
          12. - -
          13. -

            Let fragment be the result of invoking the HTML fragment parsing - algorithm given target, html, true, and - scriptingMode.

            - -

            Scripts in fragment will only execute once inserted into - target.

            -
          14. - -
          15. Sanitize fragment given sanitizer and - safe.

          16. - -
          17. Replace all with fragment within - target.

          18. -
          -

          To get a sanitizer instance from options from a dictionary options with a From e9aa4f11d6a9e8b554fb49a846d916587ed905b5 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Mon, 13 Jul 2026 20:35:42 +0100 Subject: [PATCH 02/12] TrustedParseOptions in IDL --- source | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source b/source index 06e383d5118..3cdc8863c61 100644 --- a/source +++ b/source @@ -4993,6 +4993,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute

        10. TrustedScript
        11. data
        12. TrustedScriptURL
        13. +
        14. TrustedParserOptions
        15. get trusted type compliant string
        16. get trusted type compliant input
        17. @@ -11635,7 +11636,7 @@ typedef (HTMLScriptElement or SVGScriptElement) LegacyOverrideBuiltIns] partial interface Document { - static Document parseHTMLUnsafe((TrustedHTML or DOMString) html, optional ParseHTMLUnsafeOptions options = {}); + static Document parseHTMLUnsafe((TrustedHTML or DOMString) html, optional (ParseHTMLUnsafeOptions or TrustedParserOptions) options = {}); static Document parseHTML(DOMString html, optional SetHTMLOptions options = {}); // resource metadata management @@ -125451,7 +125452,7 @@ document.body.appendChild(frame)
          partial interface Element {
             [CEReactions] undefined setHTML(DOMString html, optional SetHTMLOptions options = {});
          -  [CEReactions] undefined setHTMLUnsafe((TrustedHTML or DOMString) html, optional SetHTMLUnsafeOptions options = {});
          +  [CEReactions] undefined setHTMLUnsafe((TrustedHTML or DOMString) html, optional (SetHTMLUnsafeOptions or TrustedParserOptions) options = {});
             DOMString getHTML(optional GetHTMLOptions options = {});
           
             [CEReactions] attribute (TrustedHTML or [LegacyNullToEmptyString] DOMString) innerHTML;
          @@ -125461,7 +125462,7 @@ document.body.appendChild(frame)
          partial interface ShadowRoot { [CEReactions] undefined setHTML(DOMString html, optional SetHTMLOptions options = {}); - [CEReactions] undefined setHTMLUnsafe((TrustedHTML or DOMString) html, optional SetHTMLUnsafeOptions options = {}); + [CEReactions] undefined setHTMLUnsafe((TrustedHTML or DOMString) html, optional (SetHTMLUnsafeOptions or TrustedParserOptions) options = {}); DOMString getHTML(optional GetHTMLOptions options = {}); [CEReactions] attribute (TrustedHTML or [LegacyNullToEmptyString] DOMString) innerHTML; From 9270dec4199e717229b657fe27f383201a0918bd Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Mon, 13 Jul 2026 22:22:10 +0100 Subject: [PATCH 03/12] Still wrap things in set and filter HTML --- source | 124 ++++++++++++++++++++++++++++++++------------------------- 1 file changed, 69 insertions(+), 55 deletions(-) diff --git a/source b/source index 3cdc8863c61..41f146dfa13 100644 --- a/source +++ b/source @@ -125732,12 +125732,8 @@ enum DOMParserSupportedType {
        18. Let target be this's template contents if this is a template element; otherwise this.

        19. -
        20. Let fragment be the result of invoking the fragment parsing algorithm - steps given target, html, options, and "remove".

        21. - -
        22. If fragment is non-null, then replace - all with fragment within target.

        23. +
        24. Set and filter HTML given target, + html, and options.

        @@ -125747,12 +125743,8 @@ enum DOMParserSupportedType { steps are:

          -
        1. Let fragment be the result of invoking the fragment parsing algorithm - steps given this, html, options, and "remove".

        2. - -
        3. If fragment is non-null, then replace - all with fragment within this.

        4. +
        5. Set and filter HTML given this, + html, and options.

        @@ -125771,12 +125763,9 @@ enum DOMParserSupportedType {
      8. Let target be this's template contents if this is a template element; otherwise this.

      9. -
      10. Let fragment be the result of invoking the fragment parsing algorithm - steps given target, compliantHTML, compliantOptions, and - "keep".

      11. - -
      12. If fragment is non-null, then replace - all with fragment within target.

      13. +
      14. Set and filter HTML given target, + compliantHTML, compliantOptions, and Unsafe.

      @@ -125792,12 +125781,9 @@ enum DOMParserSupportedType { object, html, options, and "ShadowRoot setHTMLUnsafe".

      -
    8. Let fragment be the result of invoking the fragment parsing algorithm - steps given this, compliantHTML, compliantOptions, and - "keep".

    9. - -
    10. If fragment is non-null, then replace - all with fragment within this.

    11. +
    12. Set and filter HTML given this, + compliantHTML, compliantOptions, and Unsafe.

    @@ -125976,12 +125962,46 @@ enum DOMParserSupportedType { +

    A fragment parser mode is one of the following:

    + +
    +
    Legacy
    +
    Unsafe elements and attributes are allowed, + while declarative shadow roots are ignored. + XML documents are parsed using the XML parser.
    + +
    Unsafe
    +
    Unsafe elements and attributes are allowed, + alongside declarative shadow roots.
    + +
    Normal
    +
    Unsafe elements and attributes are removed, + while declarative shadow roots are + allowed.
    +
    + +
    +

    To set and filter HTML, given an Element or + DocumentFragment target, a string html, a dictionary or TrustedParserOptions object options, and an + optional fragment parser mode mode (default Normal):

    + +
      +
    1. Let fragment be the result of invoking the fragment parsing algorithm + steps given target, html, options, and + mode.

    2. + +
    3. If fragment is non-null, then replace + all with fragment within target.

    4. +
    +
    +

    The fragment parsing algorithm steps, given an Element or - DocumentFragment target, a string markup, a dictionary - options, and unsafeMarkupHandling, which is one of "remove", "keep", or "legacy", - are:

    + DocumentFragment target, a string markup, a dictionary or TrustedParserOptions object options, and a + fragment parser mode mode, are:

    1. Let context be target if target is an @@ -125993,17 +126013,17 @@ enum DOMParserSupportedType {

    2. If all of the following are true:

        -
      • unsafeMarkupHandling is "remove";
      • +
      • mode is Normal;
      • context's local name is - "script"; and
      • -
      • context's namespace is the - HTML namespace or the SVG namespace,
      • + "script"; and
      • context's namespace is the HTML namespace or the + SVG namespace,

      then return null.

    3. -
    4. Let safe be true if unsafeMarkupHandling is "remove"; otherwise false.

    5. +
    6. Let safe be true if mode is Normal; otherwise false.

    7. Let sanitizer be the result of calling getting a sanitizer from options given safe.

    8. @@ -126014,18 +126034,18 @@ enum DOMParserSupportedType {

      If options["runScripts"] is true:

        -
      1. Assert: unsafeMarkupHandling is not "remove".

      2. +
      3. Assert: mode is not Normal.

      4. Set scriptingMode to Fragment.

      -
    9. Let allowDeclarativeShadowRoots be false if unsafeMarkupHandling is - "legacy"; otherwise true.

    10. +
    11. Let allowDeclarativeShadowRoots be false if mode is Legacy; otherwise true.

    12. -
    13. If unsafeMarkupHandling is "legacy" and +

    14. If mode is Legacy and target's node document is an XML document, then return the result of invoking the XML fragment parsing algorithm given target and markup.

    15. @@ -126064,12 +126084,9 @@ enum DOMParserSupportedType { object, the given value, a new SetHTMLUnsafeOptions dictionary, and "Element innerHTML".

      -
    16. Let fragment be the result of invoking the fragment parsing algorithm - steps given this, compliantString, compliantOptions, - and "legacy".

    17. - -
    18. Replace all with fragment within - this.

    19. +
    20. Set and filter HTML given this, + compliantString, compliantOptions, and Legacy.

    @@ -126084,12 +126101,9 @@ enum DOMParserSupportedType { object, the given value, a new SetHTMLUnsafeOptions dictionary, and "ShadowRoot innerHTML".

    -
  • Let fragment be the result of invoking the fragment parsing algorithm - steps given this, compliantString, compliantOptions, - and "legacy".

  • - -
  • Replace all with fragment - within this.

  • +
  • Set and filter HTML given this, + compliantString, compliantOptions, and Legacy.

  • @@ -126165,7 +126179,7 @@ enum DOMParserSupportedType {
  • Let fragment be the result of invoking the fragment parsing algorithm steps given parent, compliantString, compliantOptions, - and "legacy".

  • + and Legacy.

  • Replace this with fragment within this's parent.

  • @@ -126271,7 +126285,7 @@ enum DOMParserSupportedType {
  • Let fragment be the result of invoking the fragment parsing algorithm steps given context, compliantString, compliantOptions, - and "legacy".

  • + and Legacy.

  • Use the first matching item from this list:
    @@ -126385,8 +126399,8 @@ enum DOMParserSupportedType {
  • Return the result of invoking the fragment parsing algorithm steps given - element, compliantString, compliantOptions, and "legacy".

  • + element, compliantString, compliantOptions, and Legacy.

    From 75bc5e8d3b9bbac35c3c9231fb2dca103231c563 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Fri, 17 Jul 2026 14:13:19 +0100 Subject: [PATCH 04/12] Add clarification about XMLL vs HTML --- source | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source b/source index 41f146dfa13..b5bba121bb6 100644 --- a/source +++ b/source @@ -125972,12 +125972,13 @@ enum DOMParserSupportedType {
    Unsafe
    Unsafe elements and attributes are allowed, - alongside declarative shadow roots.
    + alongside declarative shadow roots. The + HTML parser is used regardless of the type of document.
    Normal
    Unsafe elements and attributes are removed, - while declarative shadow roots are - allowed.
    + while declarative shadow roots are allowed. + The HTML parser is used regardless of the type of document.
    From 6993d7519c301ca310223a38a30da3ea0d785a82 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Wed, 5 Aug 2026 13:58:32 +0100 Subject: [PATCH 05/12] Some fixes from ChatGPT --- source | 63 +++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 20 deletions(-) diff --git a/source b/source index b5bba121bb6..2631aa53c7a 100644 --- a/source +++ b/source @@ -4993,9 +4993,10 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • TrustedScript
  • data
  • TrustedScriptURL
  • -
  • TrustedParserOptions
  • +
  • TrustedParserOptions
  • get trusted type compliant string
  • get trusted type compliant input
  • +
  • TrustedParserOptions sanitizer config
  • @@ -125732,8 +125733,8 @@ enum DOMParserSupportedType {
  • Let target be this's template contents if this is a template element; otherwise this.

  • -
  • Set and filter HTML given target, - html, and options.

  • +
  • Set and filter HTML given target, html, and + options.

  • @@ -125743,8 +125744,8 @@ enum DOMParserSupportedType { steps are:

      -
    1. Set and filter HTML given this, - html, and options.

    2. +
    3. Set and filter HTML given this, html, and + options.

    @@ -125763,8 +125764,8 @@ enum DOMParserSupportedType {
  • Let target be this's template contents if this is a template element; otherwise this.

  • -
  • Set and filter HTML given target, - compliantHTML, compliantOptions, and

    Set and filter HTML given target, compliantHTML, + compliantOptions, and Unsafe.

  • @@ -126046,10 +126047,23 @@ enum DOMParserSupportedType {
  • Let allowDeclarativeShadowRoots be false if mode is Legacy; otherwise true.

  • -
  • If mode is Legacy and - target's node document is an XML - document, then return the result of invoking the XML fragment parsing - algorithm given target and markup.

  • +
  • +

    If mode is Legacy and + target's node document is an XML + document, then: + +

      +
    1. +

      Assert: sanitizer is null.

      + +

      Sanitization is only supported on HTML documents. Trusted types throws when a + policy assigns a sanitizer when applying to XML documents.

      +
    2. + +
    3. Return the result of invoking the XML fragment parsing algorithm given + target and markup.

    4. +
    +
  • Let fragment be the result of the HTML fragment parsing algorithm given target, markup, allowDeclarativeShadowRoots, and @@ -126079,14 +126093,17 @@ enum DOMParserSupportedType { are:

      -
    1. Let (compliantString, compliantOptions) be the result of invoking - the get trusted type compliant input algorithm with - TrustedHTML, this's relevant global - object, the given value, a new SetHTMLUnsafeOptions dictionary, and "Element innerHTML".

    2. +
    3. Let (compliantString, compliantOptions) be the result of invoking + the get trusted type compliant input algorithm with + TrustedHTML, this's relevant global + object, the given value, a new SetHTMLUnsafeOptions dictionary, and "Element innerHTML".

    4. -
    5. Set and filter HTML given this, - compliantString, compliantOptions, and

      Let target be this's template contents if + this is a template element; otherwise this.

    6. + +
    7. Set and filter HTML given target, compliantString, + compliantOptions, and Legacy.

    @@ -127768,13 +127785,19 @@ dictionary SanitizerConfig {
    -

    To get a sanitizer instance from options from a dictionary options with a - boolean safe:

    +

    To get a sanitizer instance from options from a TrustedParserOptions or dictionary options, + given a boolean safe:

    1. Let sanitizerSpec be "default".

    2. +
    3. If options is a TrustedParserOptions, then set sanitizerSpec + to options's sanitizer + config.

    4. +
    5. If options["sanitizer"] exists, then set sanitizerSpec to options["sanitizer"].

    6. From 39fd32e5460a587a22adfff952c8bc23cff0b159 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Wed, 5 Aug 2026 14:31:44 +0100 Subject: [PATCH 06/12] Throw when applying sanitizer to XML document in a legacy method --- source | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/source b/source index 2631aa53c7a..7e20c60a00b 100644 --- a/source +++ b/source @@ -126054,10 +126054,9 @@ enum DOMParserSupportedType {
      1. -

        Assert: sanitizer is null.

        +

        If sanitizer is non-null, then throw a TypeError.

        -

        Sanitization is only supported on HTML documents. Trusted types throws when a - policy assigns a sanitizer when applying to XML documents.

        +

        Sanitization is only supported on HTML documents.

      2. Return the result of invoking the XML fragment parsing algorithm given @@ -126089,15 +126088,15 @@ enum DOMParserSupportedType {

    -

    Element's innerHTML setter steps - are:

    +

    Element's innerHTML setter steps given + value are:

    1. Let (compliantString, compliantOptions) be the result of invoking the get trusted type compliant input algorithm with - TrustedHTML, this's relevant global - object, the given value, a new SetHTMLUnsafeOptions dictionary, and "Element innerHTML".

    2. + this's relevant global object, value, a new + SetHTMLUnsafeOptions dictionary, and "Element + innerHTML".

    3. Let target be this's template contents if this is a template element; otherwise this.

    4. @@ -126109,15 +126108,15 @@ enum DOMParserSupportedType {
    -

    ShadowRoot's innerHTML setter - steps are:

    +

    ShadowRoot's innerHTML setter steps + given value are:

    1. Let (compliantString, compliantOptions) be the result of invoking the get trusted type compliant input algorithm with - TrustedHTML, this's relevant global - object, the given value, a new SetHTMLUnsafeOptions dictionary, and "ShadowRoot innerHTML".

    2. + this's relevant global object, value, a new + SetHTMLUnsafeOptions dictionary, and "ShadowRoot + innerHTML".

    3. Set and filter HTML given this, compliantString, compliantOptions, and DOMParserSupportedType {

    -

    Element's outerHTML setter steps - are:

    +

    Element's outerHTML setter steps given + value are:

    1. Let (compliantString, compliantOptions) be the result of invoking the get trusted type compliant input algorithm with - TrustedHTML, this's relevant global - object, the given value, a new SetHTMLUnsafeOptions dictionary, and "Element outerHTML".

    2. + this's relevant global object, value, a new + SetHTMLUnsafeOptions dictionary, and "Element + outerHTML".

    3. Let parent be this's parent.

    4. @@ -126257,7 +126256,7 @@ enum DOMParserSupportedType {
    5. Let (compliantString, compliantOptions) be the result of invoking the get trusted type compliant input algorithm with TrustedHTML, this's relevant global - object, the given value, a new SetHTMLUnsafeOptions dictionary, and ", string, a new SetHTMLUnsafeOptions dictionary, and "Element insertAdjacentHTML".

    6. Let context be null.

    7. From 9e7f3bf578d42f80e64a7ebab570df8d601e7eec Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Wed, 5 Aug 2026 14:39:48 +0100 Subject: [PATCH 07/12] Rebaseline to new TT changes --- source | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/source b/source index 7e20c60a00b..c94ca2526f8 100644 --- a/source +++ b/source @@ -125756,10 +125756,9 @@ enum DOMParserSupportedType {
      1. Let (compliantHTML, compliantOptions) be the result of invoking the - get trusted type compliant input algorithm with TrustedHTML, this's relevant global - object, html, options, and "Element - setHTMLUnsafe".

      2. + get trusted type compliant input algorithm with + this's relevant global object, html, options, and + "Element setHTMLUnsafe".

      3. Let target be this's template contents if this is a template element; otherwise this.

      4. @@ -125777,10 +125776,9 @@ enum DOMParserSupportedType {
        1. Let (compliantHTML, compliantOptions) be the result of invoking the - get trusted type compliant input algorithm with TrustedHTML, this's relevant global - object, html, options, and "ShadowRoot - setHTMLUnsafe".

        2. + get trusted type compliant input algorithm with + this's relevant global object, html, options, an + "ShadowRoot setHTMLUnsafe".

        3. Set and filter HTML given this, compliantHTML, compliantOptions, and DOMParserSupportedType {

          1. Let (compliantHTML, compliantOptions) be the result of invoking the - get trusted type compliant input algorithm with TrustedHTML, this's relevant global - object, html, options, and "Document - parseHTMLUnsafe".

          2. + get trusted type compliant input algorithm with + this's relevant global object, html, options, and + "Document parseHTMLUnsafe".

          3. Let document be a new Document, whose DOMParserSupportedType {

            1. Let (compliantString, compliantOptions) be the result of invoking the get trusted type compliant input algorithm with - TrustedHTML, this's relevant global - object, string, a new SetHTMLUnsafeOptions dictionary, and "Element insertAdjacentHTML".

            2. + this's relevant global object, string, a new + SetHTMLUnsafeOptions dictionary, and "Element + insertAdjacentHTML".

            3. Let context be null.

            4. From 7898aca2fc3fe649cbe1aab871fa1b81fd372358 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Wed, 5 Aug 2026 14:47:33 +0100 Subject: [PATCH 08/12] Handle default sanitizer correctly when safe is false, and fix TT throwIfMissing polarity --- source | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/source b/source index c94ca2526f8..a778b2c28c0 100644 --- a/source +++ b/source @@ -125474,11 +125474,11 @@ dictionary SetHTMLOptions { (Sanitizer or SanitizerConfig or SanitizerPresets) sanitizer = "default"; }; dictionary SetHTMLUnsafeOptions { - (Sanitizer or SanitizerConfig or SanitizerPresets) sanitizer = {}; + (Sanitizer or SanitizerConfig or SanitizerPresets) sanitizer; boolean runScripts = false; }; dictionary ParseHTMLUnsafeOptions { - (Sanitizer or SanitizerConfig or SanitizerPresets) sanitizer = {}; + (Sanitizer or SanitizerConfig or SanitizerPresets) sanitizer; }; dictionary GetHTMLOptions { @@ -127786,17 +127786,28 @@ dictionary SanitizerConfig { given a boolean safe:

                -
              1. Let sanitizerSpec be "default".

              2. +
              3. Let sanitizerSpec be null.

              4. If options is a TrustedParserOptions, then set sanitizerSpec to options's sanitizer config.

              5. -
              6. If options["sanitizer"] - exists, then set sanitizerSpec to - options["sanitizer"].

              7. +
              8. If options is a dictionary and options["sanitizer"] exists, + then set sanitizerSpec to options["sanitizer"].

              9. + +
              10. +

                If sanitizerSpec is null:

                + +
                  +
                1. If safe is true, then set sanitizerSpec to "default".

                2. + +
                3. Otherwise, return null.

                4. +
                +
              11. Assert: sanitizerSpec is either a Sanitizer instance, a SanitizerPresets member, or a SanitizerConfig dictionary.

              12. From 7a459b60c04b7bc5eb674181779cdb8cf778ccaf Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Wed, 5 Aug 2026 14:50:15 +0100 Subject: [PATCH 09/12] Revert "Handle default sanitizer correctly when safe is false, and fix TT throwIfMissing polarity" This reverts commit 7898aca2fc3fe649cbe1aab871fa1b81fd372358. --- source | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/source b/source index a778b2c28c0..c94ca2526f8 100644 --- a/source +++ b/source @@ -125474,11 +125474,11 @@ dictionary SetHTMLOptions { (Sanitizer or SanitizerConfig or SanitizerPresets) sanitizer = "default"; }; dictionary SetHTMLUnsafeOptions { - (Sanitizer or SanitizerConfig or SanitizerPresets) sanitizer; + (Sanitizer or SanitizerConfig or SanitizerPresets) sanitizer = {}; boolean runScripts = false; }; dictionary ParseHTMLUnsafeOptions { - (Sanitizer or SanitizerConfig or SanitizerPresets) sanitizer; + (Sanitizer or SanitizerConfig or SanitizerPresets) sanitizer = {}; }; dictionary GetHTMLOptions { @@ -127786,28 +127786,17 @@ dictionary SanitizerConfig { given a boolean safe:

                  -
                1. Let sanitizerSpec be null.

                2. +
                3. Let sanitizerSpec be "default".

                4. If options is a TrustedParserOptions, then set sanitizerSpec to options's sanitizer config.

                5. -
                6. If options is a dictionary and options["sanitizer"] exists, - then set sanitizerSpec to options["sanitizer"].

                7. - -
                8. -

                  If sanitizerSpec is null:

                  - -
                    -
                  1. If safe is true, then set sanitizerSpec to "default".

                  2. - -
                  3. Otherwise, return null.

                  4. -
                  -
                9. +
                10. If options["sanitizer"] + exists, then set sanitizerSpec to + options["sanitizer"].

                11. Assert: sanitizerSpec is either a Sanitizer instance, a SanitizerPresets member, or a SanitizerConfig dictionary.

                12. From f7bd6e2da667973b48a6c43459a22499c43f3877 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Wed, 5 Aug 2026 14:55:31 +0100 Subject: [PATCH 10/12] Handle null in TrustedParserOptions --- source | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/source b/source index c94ca2526f8..b13437f8daf 100644 --- a/source +++ b/source @@ -127789,14 +127789,24 @@ dictionary SanitizerConfig {
                13. Let sanitizerSpec be "default".

                14. -
                15. If options is a TrustedParserOptions, then set sanitizerSpec - to options's sanitizer - config.

                16. - -
                17. If options["sanitizer"] - exists, then set sanitizerSpec to - options["sanitizer"].

                18. +
                19. +

                  If options is a TrustedParserOptions, then:

                  + +
                    +
                  1. If options's sanitizer config is null, then return + null.

                  2. + +
                  3. Set sanitizerSpec to options's sanitizer config.

                  4. +
                  +
                20. + +
                21. Otherwise, if options["sanitizer"] exists, + then set sanitizerSpec to options["sanitizer"].

                22. Assert: sanitizerSpec is either a Sanitizer instance, a SanitizerPresets member, or a SanitizerConfig dictionary.

                23. From fd52de7b711937396855dab3ded390601661303a Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Wed, 5 Aug 2026 15:57:53 +0100 Subject: [PATCH 11/12] Fix ccf --- source | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source b/source index b13437f8daf..b231dfa7ee0 100644 --- a/source +++ b/source @@ -126377,8 +126377,8 @@ enum DOMParserSupportedType {
                  1. Let (compliantString, compliantOptions) be the result of invoking the get trusted type compliant input algorithm with - TrustedHTML, this's relevant global - object, string, a new SetHTMLUnsafeOptions whose this's relevant global object, string, a new + SetHTMLUnsafeOptions whose runScripts is true, and "Range createContextualFragment".

                  2. From 3bd7eaa7737e25664dd7f4604b4ac737cfc99f38 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Thu, 6 Aug 2026 11:32:16 +0100 Subject: [PATCH 12/12] Add some null checks --- source | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source b/source index b231dfa7ee0..483cdd18bd9 100644 --- a/source +++ b/source @@ -125813,8 +125813,8 @@ enum DOMParserSupportedType {
                  3. Let sanitizer be the result of calling get a sanitizer instance from options with options and true.

                  4. -
                  5. Call sanitize on document with sanitizer and - true.

                  6. +
                  7. If sanitizer is not null, then sanitize document with + sanitizer and true.

                  8. Return document.

                  @@ -125851,8 +125851,8 @@ enum DOMParserSupportedType {
                24. Let sanitizer be the result of calling get a sanitizer instance from options with compliantOptions and false.

                25. -
                26. Call sanitize on document with sanitizer and - false.

                27. +
                28. If sanitizer is not null, then sanitize document with + sanitizer and false.

                29. Return document.

                @@ -126065,8 +126065,8 @@ enum DOMParserSupportedType { given target, markup, allowDeclarativeShadowRoots, and scriptingMode.

                -
              13. Sanitize fragment given sanitizer and - safe.

              14. +
              15. If sanitizer is not null, then sanitize fragment given + sanitizer and safe.

              16. Return fragment.