diff --git a/source b/source index a6b93957fa3..439edb92726 100644 --- a/source +++ b/source @@ -4993,7 +4993,9 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
  • TrustedScript
  • data
  • TrustedScriptURL
  • +
  • TrustedParserOptions
  • get trusted type compliant string
  • +
  • get trusted type compliant input
  • @@ -11634,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 @@ -125447,7 +125449,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;
    @@ -125457,7 +125459,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; @@ -125727,8 +125729,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, - options, and true.

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

  • @@ -125738,8 +125740,8 @@ enum DOMParserSupportedType { steps are:

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

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

    @@ -125749,17 +125751,18 @@ 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. Set and filter HTML given target, + compliantHTML, compliantOptions, and Unsafe.

    @@ -125769,14 +125772,15 @@ 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. Set and filter HTML given this, compliantHTML, - options, and false.

    4. +
    5. Set and filter HTML given this, + compliantHTML, compliantOptions, and Unsafe.

    @@ -125820,11 +125824,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. @@ -125955,23 +125959,103 @@ 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. The + HTML parser is used regardless of the type of document.
    + +
    Normal
    +
    Unsafe elements and attributes are removed, + while declarative shadow roots are allowed. + The HTML parser is used regardless of the type of document.
    +
    + +
    +

    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, and an optional - parser scripting mode scriptingMode (default Inert), are:

    + DocumentFragment target, a string markup, a dictionary or TrustedParserOptions object options, and a + fragment parser mode mode, 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:

      +
        +
      • mode is Normal;
      • +
      • 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 mode is Normal; otherwise false.

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

    11. + +
    12. Let scriptingMode be Inert.

    13. + +
    14. +

      If options["runScripts"] + is true:

      +
        +
      1. Assert: mode is not Normal.

      2. -
      3. If target's node document is an XML +

      4. Set scriptingMode to Fragment.

      5. +
      +
    15. + +
    16. Let allowDeclarativeShadowRoots be false if mode is Legacy; otherwise true.

    17. + +
    18. 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.

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

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

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

    25. + +
    26. Return fragment.

    @@ -125992,29 +126076,15 @@ 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 (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. Let target be this.

    6. - -
    7. -

      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.

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

    10. - -
    11. Replace all with fragment - within target.

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

    @@ -126023,17 +126093,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 fragment be the result of invoking the fragment parsing algorithm - steps with this and compliantString.

    4. +
    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 "ShadowRoot innerHTML".

    6. -
    7. Replace all with fragment - within this.

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

    @@ -126088,30 +126156,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.

    @@ -126165,11 +126234,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. @@ -126212,10 +126281,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:
      @@ -126291,11 +126359,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. @@ -126327,9 +126396,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.

      @@ -127694,67 +127763,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