Skip to content

Add runScripts to SetHTMLUnsafeOptions - #12495

Merged
annevk merged 5 commits into
whatwg:mainfrom
noamr:run-scripts
Jun 8, 2026
Merged

annevk merged 5 commits into
whatwg:mainfrom
noamr:run-scripts

Conversation

@noamr

@noamr noamr commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

When runScripts is true, scripts are executed after the DOM is updated. This uses the "scripting mode" mechanism used by createContextualFragment.

Note that this is only valid in setHTMLUnsafe. "Safe" variants (setHTML) and variants that create a new document (pareHTMLUnsafe) never execute scripts.

Closes #10090

(See WHATWG Working Mode: Changes for more details.)


/dom.html ( diff )
/dynamic-markup-insertion.html ( diff )

@noamr

noamr commented May 27, 2026

Copy link
Copy Markdown
Contributor Author

Re multiple implementer support - I've filed WebKit/standards-positions#629 and
mozilla/standards-positions#1370 for the whole picture of HTML updates, which should cover this as well. cc @annevk @zcorpan .

Comment thread source Resolved
Comment thread source Resolved
@noamr noamr changed the title Add runScripts to SetHTMLUnsafeOptions. Add runScripts to SetHTMLUnsafeOptions May 28, 2026
@noamr

noamr commented Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

Ping? Not sure there's additional actions for me here...

@annevk annevk 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.

You can consider WebKit interested.

Comment thread source Outdated
<li><p><span>Assert</span>: <var>safe</var> is false.</p></li>

<li><p>Set <var>scriptingMode</var> to <span
data-x="scripting-mode-fragment">Fragment</span></p>.

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.

The dot is after the closing tag?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Comment thread source Outdated
HTML parser. If the <var>options</var> dictionary contains a "<code
data-x="dom-SetHTMLUnsafeOptions-sanitizer">sanitizer</code>" member, it is used to
<span>sanitize</span> the parsed fragment before it is inserted into <var>element</var>.</p></dd>
<span>sanitize</span> the parsed fragment before it is inserted into <var>element</var>. If the

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.

Double space before "If" is wrong.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Comment thread source Outdated
<span>sanitize</span> the parsed fragment before it is inserted into <var>element</var>. If the
<var>options</var> dictionary's "<code
data-x="dom-SetHTMLUnsafeOptions-runScripts">runScripts</code>" member is true, scripts contained
in <var>html</var> will be executed immediately after the DOM is updated.</p></dd>

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.

I think instead of "the DOM" we should use "the node tree" throughout.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

noamr added 5 commits June 8, 2026 13:51
When true, scripts are executed after the DOM is updated.
This uses the "scripting mode" mechanism used by `createContextualFragment`.

Closes whatwg#10090
@noamr

noamr commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

All nits fixed I think (I don't have merge rights if this is ready to be merged)

@annevk
annevk merged commit da0830e into whatwg:main Jun 8, 2026
1 check passed
annevk pushed a commit to web-platform-tests/wpt that referenced this pull request Jun 8, 2026
lando-worker Bot pushed a commit to mozilla-firefox/firefox that referenced this pull request Jun 9, 2026
…Scripts test, a=testonly

Automatic update from web-platform-tests
Remove .tentative from setHTMLUnsafe-runScripts test

See whatwg/html#12495.
--

wpt-commits: 865f9f4372b6c07b4f057c15765d2dc86e294c20
wpt-pr: 60234
zerox80 pushed a commit to zerox80/firefox that referenced this pull request Oct 16, 2026
…Scripts test, a=testonly

Automatic update from web-platform-tests
Remove .tentative from setHTMLUnsafe-runScripts test

See whatwg/html#12495.
--

wpt-commits: 865f9f4372b6c07b4f057c15765d2dc86e294c20
wpt-pr: 60234
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.

Ability to configure whether script elements should execute for setHTMLUnsafe()

2 participants