Skip to content

Commit

Permalink
Rename [TreatNullAs=EmptyString] to [LegacyNullToEmptyString]
Browse files Browse the repository at this point in the history
Part of #350.
  • Loading branch information
domenic committed Apr 8, 2020
1 parent 196ed9e commit 2e10ee3
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -6548,7 +6548,7 @@ The following extended attributes are <dfn for="extended attributes">applicable
[{{AllowShared}}],
[{{Clamp}}],
[{{EnforceRange}}], and
[{{TreatNullAs}}].
[{{LegacyNullToEmptyString}}].

<div algorithm>
The <dfn for="IDL type" lt="extended attribute associated with|extended attributes associated with">extended attributes associated with</dfn>
Expand Down Expand Up @@ -7735,7 +7735,7 @@ value when its bit pattern is interpreted as an unsigned 64 bit integer.
to an IDL {{DOMString}} value by running the following algorithm:

1. If |V| is <emu-val>null</emu-val> and the conversion is to an IDL type
[=extended attribute associated with|associated with=] the [{{TreatNullAs}}] extended
[=extended attribute associated with|associated with=] the [{{LegacyNullToEmptyString}}] extended
attribute, then return the {{DOMString}} value that represents the empty string.
1. Let |x| be <a abstract-op>ToString</a>(|V|).
1. Return the IDL {{DOMString}} value that represents the same sequence of code units as the one the ECMAScript String value |x| represents.
Expand Down Expand Up @@ -10715,34 +10715,31 @@ for the specific requirements that the use of
</div>


<h4 id="TreatNullAs" extended-attribute lt="TreatNullAs">[TreatNullAs]</h4>
<h4 id="LegacyNullToEmptyString" extended-attribute lt="LegacyNullToEmptyString" oldids="TreatNullAs">[LegacyNullToEmptyString]</h4>

<p class="advisement">
The [{{TreatNullAs}}] [=extended attribute=] is an undesirable feature.
The [{{LegacyNullToEmptyString}}] [=extended attribute=] is an undesirable feature.
It exists only so that legacy Web platform features can be specified.
It should not be used in specifications
unless required to specify the behavior of legacy APIs,
or for consistency with these APIs.
Editors who wish to use this feature are strongly advised to discuss this
by <a href="https://github.com/heycam/webidl/issues/new?title=Intent%20to%20use%20[TreatNullAs]">filing an issue</a>
by <a href="https://github.com/heycam/webidl/issues/new?title=Intent%20to%20use%20[LegacyNullToEmptyString]">filing an issue</a>
before proceeding.
</div>

If the [{{TreatNullAs}}] [=extended attribute=] appears on the {{DOMString}} type, it creates a new
If the [{{LegacyNullToEmptyString}}] [=extended attribute=] appears on the {{DOMString}} type, it creates a new
IDL type such that that when an ECMAScript <emu-val>null</emu-val> is converted to the IDL type, it
will be handled differently from its default handling. Instead of being stringified to
"<code>null</code>", which is the default, it will be converted to the empty string.

The [{{TreatNullAs}}] extended attribute must [=takes an identifier|take the identifier=]
<code>EmptyString</code>.

The [{{TreatNullAs}}] extended attribute must not be
The [{{LegacyNullToEmptyString}}] extended attribute must not be
[=extended attribute associated with|associated with=] a type that is not {{DOMString}}.

Note: This means that even <code class="idl">DOMString?</code> must not use [{{TreatNullAs}}], since
Note: This means that even <code class="idl">DOMString?</code> must not use [{{LegacyNullToEmptyString}}], since
<emu-val>null</emu-val> is a valid value of that type.

See [[#es-DOMString]] for the specific requirements that the use of [{{TreatNullAs}}] entails.
See [[#es-DOMString]] for the specific requirements that the use of [{{LegacyNullToEmptyString}}] entails.

<div class="example">
The following [=IDL fragment=] defines an interface that has one attribute whose type has the
Expand All @@ -10752,9 +10749,9 @@ See [[#es-DOMString]] for the specific requirements that the use of [{{TreatNull
[Exposed=Window]
interface Dog {
attribute DOMString name;
attribute [TreatNullAs=EmptyString] DOMString owner;
attribute [LegacyNullToEmptyString] DOMString owner;

boolean isMemberOfBreed([TreatNullAs=EmptyString] DOMString breedName);
boolean isMemberOfBreed([LegacyNullToEmptyString] DOMString breedName);
};
</pre>

Expand Down

0 comments on commit 2e10ee3

Please sign in to comment.