Skip to content

Layering: Relax HostGetSupportedImportAttributes identity requirement - #4099

Open
JinDX wants to merge 1 commit into
tc39:mainfrom
JinDX:editorial/supported-import-attributes-list-identity-refresh-20261122
Open

JinDX wants to merge 1 commit into
tc39:mainfrom
JinDX:editorial/supported-import-attributes-list-identity-refresh-20261122

Conversation

@JinDX

@JinDX JinDX commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

I opened this PR because HostGetSupportedImportAttributes requires the same List on every call, but the default implementation returns a new empty List each time.

AllImportAttributesSupported only checks whether the returned List contains each attribute key, so keeping the contents and order stable seems sufficient for this hook. This also matches HTML's existing algorithm without requiring a cached List.

@ljharb

ljharb commented Nov 22, 2026

Copy link
Copy Markdown
Member

instead of loosening the requirements, we should change the default implementation to memoize the empty list.

@nicolo-ribaudo

Copy link
Copy Markdown
Member

instead of loosening the requirements, we should change the default implementation to memoize the empty list.

I don't think there is much value in it, because none of the algorithms rely on the identity of the list (and I don't think the spec relies anywhere on the identity of lists)

@ljharb

ljharb commented Nov 22, 2026

Copy link
Copy Markdown
Member

if the spec doesn't rely on it, then i'm not sure why this change is needed - and if it does, forcing hosts to return the same identity is a stronger guarantee than simply returning the same contents, and it's never a good idea to loosen host requirements without a strong reason.

@JinDX

JinDX commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, @ljharb. I opened this PR because HostGetSupportedImportAttributes requires the same List on every call, but the default implementation returns a new empty List each time. I’m happy to keep the existing requirement and update the default to reuse the same empty List, as you suggested.

@JinDX JinDX changed the title Editorial: Clarify the stability of supported import attributes Editorial: Reuse the empty List in HostGetSupportedImportAttributes Nov 23, 2026
@nicolo-ribaudo

Copy link
Copy Markdown
Member

HTML already does not return the same list every time for this AO, but a list with the same contents: https://html.spec.whatwg.org/#hostgetsupportedimportattributes

It's much more annoying to write a memoize algorithm than not.

@nicolo-ribaudo nicolo-ribaudo added the layering affects the public spec interface and may require updates to integrating specs label Nov 23, 2026

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

Not a fan of this change, we should not introduce more hand-wavy prose like this. If identity is required it ought to be a field on Agent, and if cross-Agent stable identity is required (why??) that ought to be noted explicitly.

HTML already ignoring the current requirement suggests that list equality is a sufficient requirement.

@nicolo-ribaudo

Copy link
Copy Markdown
Member

@linusg What do you think of the first commit? 32fdff0 (this PR)

@linusg

linusg commented Nov 23, 2026

Copy link
Copy Markdown
Member

That LGTM.

@JinDX

JinDX commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the discussion. I lean toward the original change. "AllImportAttributesSupported" only checks whether the returned List contains each attribute key, so keeping the contents and order stable seems sufficient for this hook. This also matches HTML's existing algorithm without requiring a cached List.

@ljharb, is there a specific reason we need stable List identity here beyond stable contents and order?

@ljharb

ljharb commented Nov 23, 2026

Copy link
Copy Markdown
Member

To be clear, changing the requirement (the original change) is normative and requires consensus. Fixing the spec to comply with existing requirements would be editorial.

@JinDX off the top of my head I don't have a specific use case, but the wording was discussed and agreed on in plenary, and i feel very strongly that host hooks should be maximally constrained in every possible way, and variance only permitted with a strong argument from the hosts that need a constraint relaxed.

@bakkot

bakkot commented Nov 23, 2026

Copy link
Copy Markdown
Member

To be clear, changing the requirement (the original change) is normative and requires consensus. Fixing the spec to comply with existing requirements would be editorial.

I don't think there is any observable difference in any program for any possible host? So I don't think that it's normative.

@ljharb

ljharb commented Nov 23, 2026

Copy link
Copy Markdown
Member

If there's not an observable difference, then what's the point of this PR?

@nicolo-ribaudo

nicolo-ribaudo commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

I mean I'm happy to add this to the agenda and present if you think it's needed. We're past the deadline but it's so small that it's probably fine.

But I agree there is no observable difference.

what's the point of this PR?

The spec is internally self-inconsistent. It requires a property that itself does not respect and that it does not rely on.

@ljharb

ljharb commented Nov 24, 2026

Copy link
Copy Markdown
Member

I mean, either this isn't an observable difference, or it is. If it's not, then it's editorial. If it is, then it's not.

If nothing can possibly care about the identity of the list, then that also means that the default implementation can easily return the same List identify, which would match the normative requirement that has consensus.

@nicolo-ribaudo nicolo-ribaudo changed the title Editorial: Reuse the empty List in HostGetSupportedImportAttributes Layering: Relax HostGetSupportedImportAttributes identity requirement Nov 24, 2026
@nicolo-ribaudo

nicolo-ribaudo commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

It is not observable other than making some hosts potentially in violation of a requirement that has no effect on JS behavior.

This situation is as if ECMA-262 had this AO:

Double ( _x_: an integer )
  1. Return _x_ + _x_.

and both HTML and some ECMA-262 algorithms call it as Double(1.5), so somebody opens a PR doing this:

- Double ( _x_: an integer )
+ Double ( _x_: a mathematical value )
    1. Return _x_ + _x_.

Anyway, given that plenary is just next week we can talk about it in tc39/agendas#2195.

@JinDX Could you remove the second commit, so that it's clear what I will be asking for consensus for?

@JinDX
JinDX force-pushed the editorial/supported-import-attributes-list-identity-refresh-20261122 branch from cb4c4cc to 32fdff0 Compare November 24, 2026 10:26
@JinDX

JinDX commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Done. I've removed the second commit. Thanks for bringing this to plenary!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

layering affects the public spec interface and may require updates to integrating specs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants