Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add {{StringContext}} extended attribute #1392

Closed
wants to merge 13 commits into from
8 changes: 4 additions & 4 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -10270,7 +10270,7 @@ adhere to the context the string is used in.
The [{{StringContext}}] extended attribute must [=takes an identifier|take an identifier=]. The [=identifier=]
must be one of "<code>TrustedHTML</code>", "<code>TrustedScript</code>", and "<code>TrustedScriptURL</code>".
lukewarlow marked this conversation as resolved.
Show resolved Hide resolved

[{{StringContext}}] extended attribute may only annotate a type of a [=regular attribute=] or
The [{{StringContext}}] extended attribute may only annotate a type of a [=regular attribute=] or
a [=regular operation=] argument. A type annotated with the [{{StringContext}}]
extended attribute must not appear in a [=read only=] attribute.

Expand Down Expand Up @@ -11146,7 +11146,7 @@ Note: The HTML Standard defines how the validation is performed. [[!HTML]]
extended attribute [=identifier=], and the [=identifier=]
of the [=operation=] or [=extended attribute=] of the first entry in |S|.
Copy link
Member Author

Choose a reason for hiding this comment

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

Because we only need the identifier which is the same for all overloads we don't actually need to worry about which entry in the overload set is used.

Copy link
Member

Choose a reason for hiding this comment

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

But what if that overload doesn't have a StringContext annotated type?

I guess what this means is that you cannot meaningfully have overloaded StringContext types (or at least not all variants one might imagine to be possible). That seems reasonable, but I wonder if we need to make that more explicit in some way.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah based on my understanding you can't really have overloads. Like where you need the type to be different in a sub class we just switch back to using a union type and handling it manually rather than using this attribute. cc @koto in case I'm wrong.

Happy to add a note or something to make it clearer, not really sure what it should say though?

Copy link
Member

Choose a reason for hiding this comment

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

I guess I would add a paragraph to where StringContext is defined that outlines the limitations.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've added a paragraph hopefully it makes sense. Happy to adjust it if you'd like.


Note: That algorithm may [=JavaScript/throw=] a <l spec=ecmascript>{{TypeError}}</l>.
Note: That algorithm can [=JavaScript/throw=] a <l spec=ecmascript>{{TypeError}}</l>.
1. Append to |values| the result of [=converted to an IDL value|converting=]
|V| to IDL type |type|.
lukewarlow marked this conversation as resolved.
Show resolved Hide resolved
1. Set |i| to |i| + 1.
Expand Down Expand Up @@ -11354,7 +11354,7 @@ Note: The HTML Standard defines how the validation is performed. [[!HTML]]
extended attribute [=identifier=], and the [=identifier=]
of |callable|.

Note: That algorithm may [=JavaScript/throw=] a <l spec=ecmascript>{{TypeError}}</l>.
Note: That algorithm can [=JavaScript/throw=] a <l spec=ecmascript>{{TypeError}}</l>.
1. Append to |values| the result of [=converted to an IDL value|converting=]
|V| to IDL type |type|.
1. Set |i| to |i| + 1.
Expand Down Expand Up @@ -12050,7 +12050,7 @@ in which case they are exposed on every object that [=implements=] the interface
[=validate the string in context=], passing [=this=], |V|, the {{StringContext}}
extended attribute [=identifier=], and |id|.

Note: That algorithm may [=JavaScript/throw=] a <l spec=ecmascript>{{TypeError}}</l>.
Note: That algorithm can [=JavaScript/throw=] a <l spec=ecmascript>{{TypeError}}</l>.
1. |idlValue| is the result of [=converted to an IDL value|converting=] |V| to an
IDL value of |attribute|'s type.
</dd>
Expand Down