@@ -1126,93 +1126,9 @@ typedef (TrustedHTML or TrustedScript or TrustedScriptURL) TrustedType;
11261126
11271127## Integration with WebIDL ## {#webidl-integration}
11281128
1129- Issue: Keep in sync with https://github.com/heycam/webidl/pull/841.
1130-
11311129<h3 id="StringContext" extended-attribute lt="StringContext">[StringContext]</h3>
11321130
1133- This specification defines a new [{{StringContext}}] [=extended attribute=] .
1134-
1135- If the [{{StringContext}}] [=extended attribute=] appears on {{DOMString}} or {{USVString}} , it
1136- modifies how the value is converted to the IDL type, causing additional value validation to
1137- adhere to the context the string is used in.
1138-
1139- The [{{StringContext}}] extended attribute must [=takes an identifier|take an identifier=] . The [=identifier=]
1140- must be one of {{TrustedHTML}} , {{TrustedScript}} and {{TrustedScriptURL}} .
1141-
1142- Issue: Make sure this is OK, otherwise use strings and convert them to TrustedXYZ in this spec only.
1143-
1144- [{{StringContext}}] extended attribute may only annotate a type of a [=regular attribute=] or
1145- a [=regular operation=] argument. A type annotated with the [{{StringContext}}]
1146- extended attribute must not appear in a [=read only=] attribute. The [=regular attribute=] or
1147- a [=regular operation=] argument that the type annotated with the [{{StringContext}}] extended
1148- attribute appears in is its <dfn>related construct</dfn> .
1149-
1150- A type that is not {{DOMString}} or {{USVString}} must not be associated with the [{{StringContext}}] extended attribute.
1151-
1152- See the rules for converting ECMAScript values to the IDL types in [[webidl#js-DOMString]]
1153- for the specific requirements that the use of [{{StringContext}}] entails.
1154-
1155- <div class="example" id="webidl-stringcontext-example">
1156-
1157- In the following [=IDL fragment=] ,
1158- a [=variadic=] [=operation=] is declared
1159- that uses the [{{StringContext}}] [=extended attribute=]
1160- on all its arguments:
1161-
1162- <pre highlight="webidl">
1163- interface Document {
1164- undefined write([StringContext=TrustedHTML] DOMString... text);
1165- };
1166- </pre>
1167- </div>
1168-
1169- ### Extended attributes applicable to types ### {#webidl-applicable-to-types}
1170-
1171- The following extended attributes are <dfn for="extended attributes" noexport>applicable to types</dfn> :
1172- [{{AllowShared}}] ,
1173- [{{Clamp}}] ,
1174- [{{EnforceRange}}] <ins> ,
1175- [{{StringContext}}] </ins> and
1176- [{{LegacyNullToEmptyString}}] .
1177-
1178- ### Type conversion ### {#webidl-type-conversion}
1179-
1180- This specification modifies the algorithm implementing the conversion to DOMString in [[webidl#js-DOMString]] :
1181-
1182- An ECMAScript value |V| is [=converted to an IDL value|converted=]
1183- to an IDL {{DOMString}} value by running the following algorithm:
1184-
1185- 1. <ins> If the conversion is to an IDL type associated with the
1186- [{{StringContext}}] extended attribute, then set |V| to the result of [=validate the string in context=] , passing
1187- [=this=] , |V|, the {{StringContext}} extended attribute [=identifier=] , and the [=identifier=]
1188- of the [{{StringContext}}] extended attribute [=related construct=] .
1189-
1190- Note: That algorithm may throw a TypeError.
1191- </ins>
1192- 1. If |V| is <emu-val> null</emu-val> and the conversion is to an IDL type
1193- associated with the [{{LegacyNullToEmptyString}}] extended
1194- attribute, then return the {{DOMString}} value that represents the empty string.
1195- 1. Let |x| be <a abstract-op>ToString</a> (|V|).
1196- 1. Return the IDL {{DOMString}} value that represents the same sequence of code units as the one the ECMAScript String value |x| represents.
1197-
1198- ### Validate the string in context ### {#webidl-validate-the-string-in-context}
1199-
1200- This specification adds a following section to [[webidl#js-security]] .
1201-
1202- Certain algorithms in [[webidl#js-type-mapping]] are defined to
1203- <dfn id="dfn-validate-the-string-in-context" export>validate the string in context</dfn> on a given
1204- value. This check is used to determine whether a given value
1205- is appropriate for its {{StringContext}} . This validation takes the following four inputs:
1206-
1207- 1. the [=platform object=] on
1208- which the operation invocation or attribute access is being done,
1209- 1. the value to validate,
1210- 1. the {{StringContext}} [=identifier=] , and
1211- 1. the [=identifier=] of the operation or attribute.
1212-
1213- The algorithm returns an ECMAScript String value, or throws a TypeError.
1214-
1215- Note: The HTML Standard defines how the validation is performed. [[!HTML]]
1131+ Issue: See [https://github.com/whatwg/webidl/pull/1392] (https://github.com/whatwg/webidl/pull/1392).
12161132
12171133## Integration with HTML ## {#integration-with-html}
12181134
0 commit comments