Re: [whatwg/webidl] Add `{{StringContext}}` extended attribute (PR #1392)

@lukewarlow commented on this pull request.



> +If the [{{StringContext}}] [=extended attribute=] appears on {{DOMString}} or {{USVString}}, it
+modifies how the value is converted to the IDL type, causing additional value validation to
+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>".
+
+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.
+
+A type that is not {{DOMString}} or {{USVString}} must not be [=extended attributes associated with|associated with=]
+the [{{StringContext}}] extended attribute.
+
+The [{{StringContext}}] extended attribute must not be used on only some of the [=overloaded|overloads=] of an
+[=overloaded=] [=operation=].

Off the top of my head I *think* it's that if they're in the same position they have to always or never be annotated. It might also be the case that you can't have an overload where it's an annotated string in one branch, and a different type entirely in another.

The attribute has a side effect and that means these limitations have to be in place.

I'll be honest I'm not super familar with the IDL overloading so I might be missing the point entirely.

@annevk can probably explain it better.

Happy to reword this paragraph to make more sense :)

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/webidl/pull/1392#discussion_r1551539280
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/webidl/pull/1392/review/1979662319@github.com>

Received on Thursday, 4 April 2024 12:00:35 UTC