Skip to content

Commit 830ae19

Browse files
SimonSapinzcorpan
authored andcommitted
[cssom] Add IDL CSSOMString, typedef of either USVString or DOMString
Implementations can choose one or the other. CSSWG resolution: w3c#1217 (comment)
1 parent 4ade736 commit 830ae19

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

cssom/Overview.bs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,41 @@ the last item. Unless otherwise specified, an empty list is serialized as the
256256
empty string.
257257

258258

259+
CSSOMString {#cssomstring-type}
260+
===============================
261+
262+
Most strings in CSSOM interfaces use the <dfn>CSSOMString</dfn> type.
263+
Each implementation chooses to define it as either {{USVString}} or {{DOMString}}:
264+
265+
<pre class=idl>
266+
typedef USVString CSSOMString;
267+
</pre>
268+
269+
Or, alternatively:
270+
271+
<pre class="def lang-webidl">
272+
typedef DOMString CSSOMString;
273+
</pre>
274+
275+
<div class=note>
276+
The difference is only observable from web content
277+
when <a>surrogate</a> code units are involved.
278+
{{DOMString}} would preserve them,
279+
whereas {{USVString}} would replace them with U+FFFD REPLACEMENT CHARACTER.
280+
281+
This choice effectively allows implementations to do this replacement,
282+
but does not require it.
283+
284+
This enables an implementation to use UTF-8 internally to represent strings in memory.
285+
Since well-formed UTF-8 specifically disallows <a>surrogate</a> code points,
286+
it effectively requires this replacement.
287+
288+
On the other hand,
289+
implementations that internally represent strings as 16-bit <a>code units</a>
290+
may prefer to avoid the cost of doing this replacement.
291+
</div>
292+
293+
259294
Media Queries {#media-queries}
260295
==============================
261296

0 commit comments

Comments
 (0)