Skip to content

[css-typed-om] Should parts of the CSS namespace be exposed on workers? #14229

Open

Description

@emilio

TypedOM currently extends the CSS namespace like this:

partial namespace CSS {
    CSSUnitValue number(double value);
    // ...
}

However, per spec the CSS namespace is only exposed on Window (via [Exposed=Window] in here).

It seems Blink at least exposes CSS.number and co in workers.

When testing more aspects of the TypedOM API in workers, it seems no engine exports the CSS factory functions in workers. I think doing that would be ok since those interfaces are exposed in workers. Maybe CSS.escape and a couple others could work in there as well, they're useful for things like FontFace.

But my understanding is that it shouldn't work per spec right now. I have some ideas of how to fix this like:

  • Make the CSS namespace definition a plain [Exposed=(Window, Worker, ...)] namespace CSS {}
  • Make the existing CSS partials except the TypedOM one [Exposed=Window].

Is there a cleaner alternative @tabatkins? I worry a bit about future specs just doing partial namespace CSS and they not realizing by default it's exposing stuff to workers.

Activity

  1. emilio commented on Jul 27, 2026

    @emilio
    CollaboratorAuthor

    It seems WebKit does not expose CSS.number() and co. in workers. So maybe the alternative is saying the spec is right and fix Blink?

    cc @lilles @janvarga @cdumez, thoughts?

  2. changed the title [-][css-typed-om] Parts of the CSS namespace should now be exposed on workers probably?[/-] [+][css-typed-om] Should parts of the CSS namespace should now be exposed on workers?[/+] on Jul 27, 2026
  3. emilio commented on Jul 27, 2026

    @emilio
    CollaboratorAuthor

    Rewording because I misunderstood @janvarga when discussing this over Matrix :)

  4. changed the title [-][css-typed-om] Should parts of the CSS namespace should now be exposed on workers?[/-] [+][css-typed-om] Should parts of the CSS namespace be exposed on workers?[/+] on Jul 27, 2026
  5. emilio commented on Jul 27, 2026

    @emilio
    CollaboratorAuthor

    It seems that you can manually construct a lot of these on a worker already via new CSSUnitValue, so this would mostly be exposing syntax sugar which is available on the main thread.

  6. janvarga commented on Jul 27, 2026

    @janvarga

    Yes, this would help with converting more Typed OM WPT to any.js

  7. javifernandez commented on Jul 27, 2026

    @javifernandez
    Contributor

    I'm working on the PR 61330 to updated some of these tests to any.js

  8. lilles commented on Jul 28, 2026

    @lilles
    Member

    It seems that you can manually construct a lot of these on a worker already via new CSSUnitValue, so this would mostly be exposing syntax sugar which is available on the main thread.

    Yes. sgtm to expose this in workers (and layout and paint worklets)

    Interestingly, Chrome currently exposes a lot of these APIs in paint/layout worklets, but not workers. @javifernandez is working on fixing that.

  9. moved this to Most recent Agenda+ F2F in CSSWG summer 2026 meeting agendaon Aug 1, 2026
  10. added
    Async Resolution: Proposed
    on Oct 26, 2026
  11. astearns commented on Nov 2, 2026

    @astearns
    Member

    @javifernandez could you supply the proposed async resolution?

  12. javifernandez commented on Nov 9, 2026

    @javifernandez
    Contributor

    @javifernandez could you supply the proposed async resolution?

    Proposed resolution: "Make the CSS namespace definition a plain [Exposed=(Window, Worker, ...)] namespace CSS {}, pining specific partial namespaces to Window context, when needed."

  13. astearns commented on Nov 16, 2026

    @astearns
    Member

    The CSSWG will automatically accept this resolution one week from now if no objections are raised here. Anyone can add an emoji to this comment to express support. If you do not support this resolution, please add a new comment.

    Proposed Resolution: Make the CSS namespace definition a plain [Exposed=(Window, Worker, ...)] namespace CSS {}, pinning specific partial namespaces to Window context, when needed.

  14. added
    Async Resolution: Call For Consensus
    and removed
    Async Resolution: Proposed
    on Nov 16, 2026
  15. astearns commented on Nov 24, 2026

    @astearns
    Member

    RESOLVED: Make the CSS namespace definition a plain [Exposed=(Window, Worker, ...)] namespace CSS {}, pinning specific partial namespaces to Window context, when needed.

  16. added and removed
    Async Resolution: Call For Consensus
    on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions