Skip to content

Meta element and DOM post-insertion steps #10241

Open

Description

@domfarolino

What is the issue with the HTML Standard?

The processing of http-equiv meta tags is currently done in the insertion steps (see this usage and this usage), meaning it happens synchronously upon insertion, before the post-insertion steps (which all browsers seem to have some form of) run.

But implementations don't seem to do this. See this test: https://wpt.fyi/results/dom/nodes/insertion-removing-steps/Node-appendChild-script-and-default-style-meta-from-fragment.tentative.html?label=experimental&label=master&aligned. All browsers currently fail it (except for Edge, mysteriously), because Blink, WebKit, and Gecko (though I can't find the exact source code for this) all process http-equiv in the post-insertion steps.

Once whatwg/dom#1261 lands (🤞), we should update the spec to use the post-insertion steps for this kind of meta tag, to match implementations. In the meantime, I will update the test expectations.


There's an open question about what we should do with name/content meta elements. Both Chromium and WebKit also process these kinds of meta tags in the post-insertion steps, so I suppose we should update the following instances:

... to use the post-insertion steps too, to at least match 2/3 browser implementations. See https://wpt.fyi/results/dom/nodes/insertion-removing-steps/Node-append-meta-referrer-and-script-from-fragment.tentative.html?label=experimental&label=master&aligned. Given this, Gecko would be the odd one out and we'd file a bug against Gecko to start processing these kinds of meta elements in the post-insertion steps.


If anyone disagrees with this analysis and my recommendations above, let me know! I'll prepare spec PRs once the post-insertion steps primitive is a thing.

Activity

  1. domfarolino commented on Apr 1, 2024

    @domfarolino
    MemberAuthor

    cc @smaug----, for the deviation from WebKit and Blink that we're observing with Gecko (regarding http-equiv and name/content meta tags).

  2. self-assigned this
    on Apr 1, 2024
  3. domenic commented on Apr 2, 2024

    @domenic
    Member

    Do you know why browsers don't use the normal insertion steps for these? It seems very strange.

  4. domfarolino commented on Apr 2, 2024

    @domfarolino
    MemberAuthor

    I looked into this a bit thanks to your comment. Apparently HTMLMetaElement can (or at least once could) run script synchronously, which is absolutely not allowed during the normal insertion steps, so its entire processing phase got relegated to the post-insertion steps.

    Assuming it still can run script synchronously for some meta types, I kind of imagine we could technically pull the non-script-running types into the "insertion steps", and keep only the script-running-types in the "post-insertion steps" but I'm not sure that buys us very much and it would require Blink & WebKit to change their longstanding behavior with probably very little upside for the vendors, so I'm not sure it's worth it.

  5. domenic commented on Apr 2, 2024

    @domenic
    Member

    It's pretty hard to imagine how any meta elements could run scripts. I agree probably implementers won't want to invest any effort in changing this, but I wish we would, because this is bizarre.

  6. domfarolino commented on Apr 2, 2024

    @domfarolino
    MemberAuthor

    Yeah the only thing I can imagine would be unload or pagehide in a meta refresh, but those are actually unconditionally scheduled asynchronously anyways, so the script wouldn't run right away. I'll try and sniff around for other cases that motivated the original change, to see if they're still relevant.

  7. smaug---- commented on Apr 2, 2024

    @smaug----

    Are you sure default-style is processed at all in that testcase?

  8. domfarolino commented on Apr 2, 2024

    @domfarolino
    MemberAuthor

    Yep, in the post-insertion steps.

  9. added 2 commits that reference this issue on Apr 10, 2024
  10. added a commit that references this issue on Jun 5, 2024
  11. added a commit that references this issue on Jun 20, 2024
  12. added
    interop
    topic: document metadata
    on Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

interoptopic: document metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions