Skip to content

Commit c84e3f0

Browse files
committed
merging PR #84: ECMA-402 v1 legacy constructor semantics compromise
2 parents 2a77f67 + 8775fdc commit c84e3f0

File tree

5 files changed

+93
-6
lines changed

5 files changed

+93
-6
lines changed

spec/conventions.html

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ <h1>Notational Conventions</h1>
2424
For ECMAScript objects, this standard may use variable-named internal slots: The notation "[[&lt;_name_&gt;]]" denotes an internal slot whose name is given by the variable name, which must have a String value. For example, if a variable _s_ has the value *"a"*, then [[&lt;_s_&gt;]] denotes the [[&lt;_a_&gt;]] internal slot.
2525
</p>
2626

27+
<p>
28+
This specification uses blocks demarcated as <span class="normative-optional">Normative Optional</span> to denote the sense of <a href="https://tc39.github.io/ecma262/#sec-additional-ecmascript-features-for-web-browsers">Annex B</a> in ECMA 262. That is, normative optional sections are required when the ECMAScript host is a web browser. The content of the section is normative but optional if the ECMAScript host is not a web browser.
29+
</p>
30+
2731
<emu-clause id="sec-402-well-known-intrinsic-objects">
2832
<h1>Well-Known Intrinsic Objects</h1>
2933

spec/datetimeformat.html

+36-3
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,28 @@ <h1>ToLocalTime ( _date_, _calendar_, _timeZone_ )</h1>
370370
It is recommended that implementations use the time zone information of the IANA Time Zone Database.
371371
</emu-note>
372372
</emu-clause>
373+
374+
<emu-clause id="sec-unwrapdatetimeformat" aoid="UnwrapDateTimeFormat">
375+
<h1>UnwrapDateTimeFormat( _dtf_ )</h1>
376+
<p>
377+
The UnwrapDateTimeFormat abstract operation gets the underlying DateTimeFormat operation
378+
for various methods which implement ECMA-402 v1 semantics for supporting initializing
379+
existing Intl objects.
380+
</p>
381+
<emu-normative-optional><span class="normative-optional">Normative Optional</span><div class="normative-optional-contents">
382+
<emu-alg>
383+
1. If _dtf_ does not have an [[InitializedDateTimeFormat]] internal slot and ? InstanceofOperator(_dtf_, %DateTimeFormat%) is equal *true*, then
384+
1. Let _obj_ be Get(_dtf_, Intl.[[FallbackSymbol]]).
385+
1. Let _dtf_ be ? RequireObjectCoercible(_obj_).
386+
</emu-alg>
387+
</div></emu-normative-optional>
388+
<emu-alg>
389+
2. If _dtf_ does not have an [[InitializedDateTimeFormat]] internal slot,
390+
1. Throw a *TypeError* exception.
391+
1. Return _dtf_.
392+
</emu-alg>
393+
</emu-clause>
394+
</emu-clause>
373395
</emu-clause>
374396

375397
<emu-clause id="sec-intl-datetimeformat-constructor">
@@ -389,7 +411,18 @@ <h1>Intl.DateTimeFormat ( [ _locales_ [ , _options_ ] ] )</h1>
389411
<emu-alg>
390412
1. If NewTarget is *undefined*, let _newTarget_ be the active function object, else let _newTarget_ be NewTarget.
391413
1. Let _dateTimeFormat_ be ? OrdinaryCreateFromConstructor(_newTarget_, `"%DateTimeFormatPrototype%"`, &laquo; [[InitializedIntlObject]], [[InitializedDateTimeFormat]], [[Locale]], [[Calendar]], [[NumberingSystem]], [[TimeZone]], [[Weekday]], [[Era]], [[Year]], [[Month]], [[Day]], [[Hour]], [[Minute]], [[Second]], [[TimeZoneName]], [[Hour12]], [[HourNo0]], [[Pattern]], [[BoundFormat]] &raquo;).
392-
1. Return ? InitializeDateTimeFormat(_dateTimeFormat_, _locales_, _options_).
414+
1. Perform ? InitializeDateTimeFormat(_dateTimeFormat_, _locales_, _options_).
415+
</emu-alg>
416+
<emu-normative-optional><span class="normative-optional">Normative Optional</span><div class="normative-optional-contents">
417+
<emu-alg>
418+
4. Let _this_ be the *this* value.
419+
1. If NewTarget is *undefined* and ? InstanceofOperator(_this_, %NumberFormat%),
420+
1. Perform ? DefineOwnPropertyOrThrow(_this_, Intl.[[FallbackSymbol]], { [[Value]]: _dateTimeFormat_, [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *false* }).
421+
1. Return _this_.
422+
</emu-alg>
423+
</div></emu-normative-optional>
424+
<emu-alg>
425+
6. Return _dateTimeFormat_.
393426
</emu-alg>
394427
</emu-clause>
395428
</emu-clause>
@@ -522,7 +555,7 @@ <h1>get Intl.DateTimeFormat.prototype.format</h1>
522555
<emu-alg>
523556
1. Let _dtf_ be *this* value.
524557
1. If Type(_dtf_) is not Object, throw a *TypeError* exception.
525-
1. If _dtf_ does not have an [[InitializedDateTimeFormat]] internal slot, throw a *TypeError* exception.
558+
1. Let _dtf_ be ? UnwrapDateTimeFormat(_dtf_).
526559
1. If _dtf_.[[BoundFormat]] is *undefined*, then
527560
1. Let _F_ be a new built-in function object as defined in DateTime Format Functions (<emu-xref href="#sec-datetime-format-functions"></emu-xref>).
528561
1. Let _bf_ be BoundFunctionCreate(_F_, _dft_, &laquo; &raquo;).
@@ -555,7 +588,7 @@ <h1>Intl.DateTimeFormat.prototype.formatToParts ( [ _date_ ] )</h1>
555588
<h1>Intl.DateTimeFormat.prototype.resolvedOptions ()</h1>
556589

557590
<p>
558-
This function provides access to the locale and formatting options computed during initialization of the object.
591+
This function provides access to the locale and formatting options computed during initialization of the object. This function initially invokes the internal algorithm UnwrapDateTimeFormat to get the %DateTimeFormat% object on which to operate.
559592
</p>
560593

561594
<p>

spec/index.html

+14
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,20 @@
2525
margin-bottom: 10px;
2626
padding-left: 10px;
2727
}
28+
29+
emu-normative-optional {
30+
margin: 1em 0;
31+
border-left: 5px solid #ff6600;
32+
display: block;
33+
background: #ffeedd;
34+
}
35+
36+
span.normative-optional {
37+
padding-left: 5px;
38+
text-transform: uppercase;
39+
color: #884400;
40+
}
41+
2842
</style>
2943
<img src="img/ecma-logo.jpg">
3044
<pre class=metadata>

spec/intl.html

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ <h1>The Intl Object</h1>
1212
The Intl object is not a function object. It does not have a [[Construct]] internal method; it is not possible to use the Intl object as a constructor with the *new* operator. The Intl object does not have a [[Call]] internal method; it is not possible to invoke the Intl object as a function.
1313
</p>
1414

15+
<p>
16+
The Intl object has an internal slot, [[FallbackSymbol]], which is a new %Symbol% in the current realm.
17+
</p>
18+
1519
<emu-clause id="sec-constructor-properties-of-the-intl-object">
1620
<h1>Constructor Properties of the Intl Object</h1>
1721

spec/numberformat.html

+35-3
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,27 @@ <h1>ToRawFixed( _x_, _minInteger_, _minFraction_, _maxFraction_ )</h1>
448448
1. Return _m_.
449449
</emu-alg>
450450
</emu-clause>
451+
452+
<emu-clause id="sec-unwrapnumberformat" aoid="UnwrapNumberFormat">
453+
<h1>UnwrapNumberFormat( _nf_ )</h1>
454+
<p>
455+
The UnwrapNumberFormat abstract operation gets the underlying NumberFormat operation
456+
for various methods which implement ECMA-402 v1 semantics for supporting initializing
457+
existing Intl objects.
458+
</p>
459+
<emu-normative-optional><span class="normative-optional">Normative Optional</span><div class="normative-optional-contents">
460+
<emu-alg>
461+
1. If _nf_ does not have an [[InitializedNumberFormat]] internal slot and ? InstanceofOperator(_nf_, %NumberFormat%)is equal *true*, then
462+
1. Let _obj_ be Get(_nf_, Intl.[[FallbackSymbol]]).
463+
1. Let _nf_ be ? RequireObjectCoercible(_obj_).
464+
</emu-alg>
465+
</div></emu-normative-optional>
466+
<emu-alg>
467+
2. If _nf_ does not have an [[InitializedNumberFormat]] internal slot, then
468+
1. Throw a *TypeError* exception.
469+
1. Return _nf_.
470+
</emu-alg>
471+
</emu-clause>
451472
</emu-clause>
452473

453474
<emu-clause id="sec-intl-numberformat-constructor">
@@ -467,7 +488,18 @@ <h1>Intl.NumberFormat ( [ _locales_ [ , _options_ ] ] )</h1>
467488
<emu-alg>
468489
1. If NewTarget is *undefined*, let _newTarget_ be the active function object, else let _newTarget_ be NewTarget.
469490
1. Let _numberFormat_ be ? OrdinaryCreateFromConstructor(_newTarget_, `"%NumberFormatPrototype%"`, &laquo; [[InitializedIntlObject]], [[InitializedNumberFormat]], [[Locale]], [[NumberingSystem]], [[Style]], [[Currency]], [[CurrencyDisplay]], [[MinimumIntegerDigits]], [[MinimumFractionDigits]], [[MaximumFractionDigits]], [[MinimumSignificantDigits]], [[MaximumSignificantDigits]], [[UseGrouping]], [[PositivePattern]], [[NegativePattern]], [[BoundFormat]] &raquo;).
470-
1. Return ? InitializeNumberFormat(_numberFormat_, _locales_, _options_).
491+
1. Perform ? InitializeNumberFormat(_numberFormat_, _locales_, _options_).
492+
</emu-alg>
493+
<emu-normative-optional><span class="normative-optional">Normative Optional</span><div class="normative-optional-contents">
494+
<emu-alg>
495+
4. Let _this_ be the *this* value.
496+
1. If NewTarget is *undefined* and ? InstanceofOperator(_this_, %NumberFormat%),
497+
1. Perform ? DefineOwnPropertyOrThrow(_this_, Intl.[[FallbackSymbol]], { [[Value]]: _numberFormat_, [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *false* }).
498+
1. Return _this_.
499+
</emu-alg>
500+
</div></emu-normative-optional>
501+
<emu-alg>
502+
6. Return _numberFormat_.
471503
</emu-alg>
472504
</emu-clause>
473505
</emu-clause>
@@ -577,7 +609,7 @@ <h1>get Intl.NumberFormat.prototype.format</h1>
577609
<emu-alg>
578610
1. Let _nf_ be *this* value.
579611
1. If Type(_nf_) is not Object, throw a *TypeError* exception.
580-
1. If _nf_.[[InitializedNumberFormat]] is *true*, throw a *TypeError* exception.
612+
1. Let _nf_ be ? UnwrapNumberFormat(_nf_);
581613
1. If _nf_.[[BoundFormat]] is *undefined*, then
582614
1. Let _F_ be a new built-in function object as defined in Number Format Functions (<emu-xref href="#sec-number-format-functions"></emu-xref>).
583615
1. Let _bf_ be BoundFunctionCreate(_F_, _nf_, &laquo; &raquo;).
@@ -591,7 +623,7 @@ <h1>get Intl.NumberFormat.prototype.format</h1>
591623
<h1>Intl.NumberFormat.prototype.resolvedOptions ()</h1>
592624

593625
<p>
594-
This function provides access to the locale and formatting options computed during initialization of the object.
626+
This function provides access to the locale and formatting options computed during initialization of the object. This function initially invokes the internal algorithm UnwrapNumberFormat to get the %NumberFormat% object on which to operate.
595627
</p>
596628
<p>
597629
The function returns a new object whose properties and attributes are set as if constructed by an object literal assigning to each of the following properties the value of the corresponding internal slot of this NumberFormat object (see <emu-xref href="#sec-properties-of-intl-numberformat-instances"></emu-xref>): locale, numberingSystem, style, currency, currencyDisplay, minimumIntegerDigits, minimumFractionDigits, maximumFractionDigits, minimumSignificantDigits, maximumSignificantDigits, and useGrouping. Properties whose corresponding internal slots have the value *undefined* are not assigned.

0 commit comments

Comments
 (0)