Skip to content

Commit 898b8d2

Browse files
authored
Editorial: use Type(x) where appropriate. (#270)
1 parent 0b1a510 commit 898b8d2

File tree

2 files changed

+116
-143
lines changed

2 files changed

+116
-143
lines changed

index.bs

Lines changed: 44 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -6557,41 +6557,27 @@ Since the IDL {{any}} type
65576557
is the union of all other IDL types, it can correspond to any
65586558
ECMAScript value type.
65596559

6560-
<p id="es-to-any">
6561-
How to [=converted to an IDL value|convert an ECMAScript value=] to an IDL {{any}} value depends on the type of the
6562-
ECMAScript value:
6563-
</p>
6560+
<div id="es-to-any" algorithm="convert an ECMAScript value to any">
65646561

6565-
<dl class="switch">
6566-
: The <emu-val>undefined</emu-val> value
6567-
:: The IDL value is an
6568-
{{object}} reference
6569-
to a special object that represents the ECMAScript
6570-
<emu-val>undefined</emu-val> value.
6571-
: The <emu-val>null</emu-val> value
6572-
:: The IDL value is the <emu-val>null</emu-val>
6573-
{{object|object?}} reference.
6574-
: A <emu-val>Boolean</emu-val> value
6575-
:: The IDL value is the
6576-
{{boolean}}
6577-
value that represents the same truth value.
6578-
: A <emu-val>Number</emu-val> value
6579-
:: The IDL value is that which is obtained
6580-
by following the rules for converting the
6581-
<emu-val>Number</emu-val> to an IDL
6582-
{{unrestricted double}} value,
6583-
as described in [[#es-unrestricted-double]].
6584-
: A <emu-val>String</emu-val> value
6585-
:: The IDL value is that which is obtained
6586-
by following the rules for converting the
6587-
<emu-val>String</emu-val> to an IDL
6588-
{{DOMString}} value,
6589-
as described in [[#es-DOMString]].
6590-
: An {{object}} value
6591-
:: The IDL value is an
6592-
{{object}} value that
6593-
references the same object.
6594-
</dl>
6562+
An ECMAScript value |V| is [=converted to an IDL value|converted=]
6563+
to an IDL {{any}} value by running the following algorithm:
6564+
6565+
1. If |V| is <emu-val>undefined</emu-val>, then
6566+
return an {{object}} reference to a special object that represents
6567+
the ECMAScript <emu-val>undefined</emu-val> value.
6568+
1. If |V| is <emu-val>null</emu-val>, then
6569+
return the <emu-val>null</emu-val> {{object|object?}} reference.
6570+
1. If [=Type=](|V|) is Boolean, then
6571+
return the {{boolean}} value that represents the same truth value.
6572+
1. If [=Type=](|V|) is Number, then
6573+
return the result of <a href="#es-to-unrestricted-double">converting</a> |V|
6574+
to an {{unrestricted double}}.
6575+
1. If [=Type=](|V|) is String, then
6576+
return the result of <a href="#es-DOMString">converting</a> |V|
6577+
to a {{DOMString}}.
6578+
1. If [=Type=](|V|) is Object, then
6579+
return an IDL {{object}} value that references |V|.
6580+
</div>
65956581

65966582
<p id="any-to-es">
65976583
An IDL {{any}} value is
@@ -7321,7 +7307,7 @@ ECMAScript <emu-val>Array</emu-val> values.
73217307
An ECMAScript value |V| is [=converted to an IDL value|converted=]
73227308
to an IDL <a lt="sequence type">sequence&lt;<var ignore>T</var>&gt;</a> value as follows:
73237309

7324-
1. If |V| is not an object,
7310+
1. If [=Type=](|V|) is not Object,
73257311
[=ECMAScript/throw=] a <emu-val>TypeError</emu-val>.
73267312
1. Let |method| be the result of
73277313
[=GetMethod=](|V|, [=@@iterator=]).
@@ -7641,8 +7627,7 @@ that correspond to the union’s [=member types=].
76417627
then return the IDL value <emu-val>null</emu-val>.
76427628
1. Let |types| be the [=flattened member types=]
76437629
of the [=union type=].
7644-
1. If |V| is <emu-val>null</emu-val> or
7645-
<emu-val>undefined</emu-val>, then:
7630+
1. If |V| is <emu-val>null</emu-val> or <emu-val>undefined</emu-val>, then:
76467631
1. If |types| includes a [=dictionary type=], then return the
76477632
result of [=converted to an IDL value|converting=] |V| to that dictionary type.
76487633
1. If |types| includes a [=record type=], then return the
@@ -7659,25 +7644,25 @@ that correspond to the union’s [=member types=].
76597644
|V| to that type.
76607645
1. If |types| includes {{object}}, then return the IDL value
76617646
that is a reference to the object |V|.
7662-
1. If |V| is a native <emu-val>Error</emu-val> object (that is, it has an \[[ErrorData]] [=internal slot=]), then:
7647+
1. If [=Type=](|V|) is Object and |V| has an \[[ErrorData]] [=internal slot=]), then:
76637648
1. If |types| includes {{Error!!interface}}, then return the
76647649
result of [=converted to an IDL value|converting=]
76657650
|V| to {{Error!!interface}}.
76667651
1. If |types| includes {{object}}, then return the IDL value
76677652
that is a reference to the object |V|.
7668-
1. If |V| is an object with an \[[ArrayBufferData]] [=internal slot=], then:
7653+
1. If [=Type=](|V|) is Object and |V| has an \[[ArrayBufferData]] [=internal slot=], then:
76697654
1. If |types| includes {{ArrayBuffer}}, then return the
76707655
result of [=converted to an IDL value|converting=]
76717656
|V| to {{ArrayBuffer}}.
76727657
1. If |types| includes {{object}}, then return the IDL value
76737658
that is a reference to the object |V|.
7674-
1. If |V| is an object with a \[[DataView]] [=internal slot=], then:
7659+
1. If [=Type=](|V|) is Object and |V| has a \[[DataView]] [=internal slot=], then:
76757660
1. If |types| includes {{DataView}}, then return the
76767661
result of [=converted to an IDL value|converting=]
76777662
|V| to {{DataView}}.
76787663
1. If |types| includes {{object}}, then return the IDL value
76797664
that is a reference to the object |V|.
7680-
1. If |V| is an object with a \[[TypedArrayName]] [=internal slot=], then:
7665+
1. If [=Type=](|V|) is Object and |V| has a \[[TypedArrayName]] [=internal slot=], then:
76817666
1. If |types| includes a [=typed array type=]
76827667
whose name is the value of |V|’s \[[TypedArrayName]] [=internal slot=], then return the
76837668
result of [=converted to an IDL value|converting=]
@@ -7691,24 +7676,22 @@ that correspond to the union’s [=member types=].
76917676
|V| to that callback function type.
76927677
1. If |types| includes {{object}}, then return the IDL value
76937678
that is a reference to the object |V|.
7694-
1. If |V| is any kind of object, then:
7679+
1. If [=Type=](|V|) is Object, then:
76957680
1. If |types| includes a [=sequence type=], then
76967681
1. Let |method| be the result of
76977682
[=GetMethod=](|V|, [=@@iterator=]).
76987683
1. [=ReturnIfAbrupt=](|method|).
7699-
1. If |method| is not
7700-
<emu-val>undefined</emu-val>,
7684+
1. If |method| is not <emu-val>undefined</emu-val>,
77017685
return the result of
77027686
[=creating a sequence from an iterable|creating a sequence=]
77037687
of that type from |V| and |method|.
77047688
1. If |types| includes a [=frozen array type=], then
7705-
1. Let |method| be the result of
7706-
[=GetMethod=](|V|, [=@@iterator=]).
7689+
1. Let |method| be the result of [=GetMethod=](|V|, [=@@iterator=]).
77077690
1. [=ReturnIfAbrupt=](|method|).
7708-
1. If |method| is not
7709-
<emu-val>undefined</emu-val>,
7691+
1. If |method| is not <emu-val>undefined</emu-val>,
77107692
return the result of
7711-
[=Creating a frozen array from an iterable|creating a frozen array of that type from V and method=].
7693+
[=Creating a frozen array from an iterable|creating a frozen array=]
7694+
of that type from |V| and |method|.
77127695
1. If |types| includes a [=dictionary type=], then return the
77137696
result of [=converted to an IDL value|converting=]
77147697
|V| to that dictionary type.
@@ -7721,11 +7704,11 @@ that correspond to the union’s [=member types=].
77217704
|V| to that interface type.
77227705
1. If |types| includes {{object}}, then return the IDL value
77237706
that is a reference to the object |V|.
7724-
1. If |V| is a <emu-val>Boolean</emu-val> value, then:
7707+
1. If [=Type=](|V|) is Boolean, then:
77257708
1. If |types| includes a {{boolean}},
77267709
then return the result of [=converted to an IDL value|converting=]
77277710
|V| to {{boolean}}.
7728-
1. If |V| is a <emu-val>Number</emu-val> value, then:
7711+
1. If [=Type=](|V|) is Number, then:
77297712
1. If |types| includes a [=numeric type=],
77307713
then return the result of [=converted to an IDL value|converting=]
77317714
|V| to that [=numeric type=].
@@ -9802,7 +9785,7 @@ Note: The HTML Standard defines how a security check is performed. [[!HTML]]
98029785

98039786
then remove from |S| all other entries.
98049787

9805-
1. Otherwise: if |V| is an <emu-val>Error</emu-val> object (that is, it has an \[[ErrorData]] [=internal slot=]) and
9788+
1. Otherwise: if [=Type=](|V|) is Object, |V| has an \[[ErrorData]] [=internal slot=], and
98069789
there is an entry in |S| that has one of the following types at position |i| of its type list,
98079790
* {{Error!!interface}}
98089791
* {{object}}
@@ -9812,7 +9795,7 @@ Note: The HTML Standard defines how a security check is performed. [[!HTML]]
98129795

98139796
then remove from |S| all other entries.
98149797

9815-
1. Otherwise: if |V| is an object with an \[[ArrayBufferData]] [=internal slot=] and
9798+
1. Otherwise: if [=Type=](|V|) is Object, |V| has an \[[ArrayBufferData]] [=internal slot=], and
98169799
there is an entry in |S| that has one of the following types at position |i| of its type list,
98179800
* {{ArrayBuffer}}
98189801
* {{object}}
@@ -9822,7 +9805,7 @@ Note: The HTML Standard defines how a security check is performed. [[!HTML]]
98229805

98239806
then remove from |S| all other entries.
98249807

9825-
1. Otherwise: if |V| is an object with a \[[DataView]] [=internal slot=] and
9808+
1. Otherwise: if [=Type=](|V|) is Object, |V| has a \[[DataView]] [=internal slot=], and
98269809
there is an entry in |S| that has one of the following types at position |i| of its type list,
98279810
* {{DataView}}
98289811
* {{object}}
@@ -9832,7 +9815,7 @@ Note: The HTML Standard defines how a security check is performed. [[!HTML]]
98329815

98339816
then remove from |S| all other entries.
98349817

9835-
1. Otherwise: if |V| is an object with a \[[TypedArrayName]] [=internal slot=] and
9818+
1. Otherwise: if [=Type=](|V|) is Object, |V| has a \[[TypedArrayName]] [=internal slot=], and
98369819
there is an entry in |S| that has one of the following types at position |i| of its type list,
98379820
* a [=typed array type=] whose name
98389821
is equal to the value of |V|’s \[[TypedArrayName]] [=internal slot=]
@@ -9853,7 +9836,7 @@ Note: The HTML Standard defines how a security check is performed. [[!HTML]]
98539836

98549837
then remove from |S| all other entries.
98559838

9856-
1. Otherwise: if |V| is any kind of object, and
9839+
1. Otherwise: if [=Type=](|V|) is Object and
98579840
there is an entry in |S| that has one of the
98589841
following types at position |i| of its type list,
98599842
* a [=sequence type=]
@@ -9871,7 +9854,7 @@ Note: The HTML Standard defines how a security check is performed. [[!HTML]]
98719854
|method| is not <emu-val>undefined</emu-val>, then remove from |S| all
98729855
other entries.
98739856

9874-
1. Otherwise: if |V| is any kind of object, and
9857+
1. Otherwise: if [=Type=](|V|) is Object and
98759858
there is an entry in |S| that has one of the following types at position |i| of its type list,
98769859
* a [=callback interface=] type
98779860
* a [=dictionary type=]
@@ -9883,7 +9866,7 @@ Note: The HTML Standard defines how a security check is performed. [[!HTML]]
98839866

98849867
then remove from |S| all other entries.
98859868

9886-
1. Otherwise: if |V| is a <emu-val>Boolean</emu-val> value,
9869+
1. Otherwise: if [=Type=](|V|) is Boolean
98879870
and there is an entry in |S| that has one of the following types at position |i| of its type list,
98889871
* {{boolean}}
98899872
* a [=nullable type|nullable=] {{boolean}}
@@ -9892,7 +9875,7 @@ Note: The HTML Standard defines how a security check is performed. [[!HTML]]
98929875

98939876
then remove from |S| all other entries.
98949877

9895-
1. Otherwise: if |V| is a <emu-val>Number</emu-val> value,
9878+
1. Otherwise: if [=Type=](|V|) is Number
98969879
and there is an entry in |S| that has one of the following types at position |i| of its type list,
98979880
* a [=numeric type=]
98989881
* a [=nullable type|nullable=] [=numeric type=]
@@ -10167,9 +10150,9 @@ whose value is the identifier of the corresponding interface.
1016710150
every [=interface object=] |A| must behave as follows,
1016810151
assuming |V| is the object argument passed to \[[HasInstance]]:
1016910152

10170-
1. If |V| is not an object, return <emu-val>false</emu-val>.
10153+
1. If Type(|V|) is not Object, return <emu-val>false</emu-val>.
1017110154
1. Let |O| be the result of calling the \[[Get]] method of |A| with property name “prototype”.
10172-
1. If |O| is not an object, [=ECMAScript/throw=] a <emu-val>TypeError</emu-val> exception.
10155+
1. If Type(|O|) is not Object, [=ECMAScript/throw=] a <emu-val>TypeError</emu-val> exception.
1017310156
1. If |V| is a platform object that implements the
1017410157
interface for which |O| is the [=interface prototype object=],
1017510158
return <emu-val>true</emu-val>.

0 commit comments

Comments
 (0)