Skip to content

Commit

Permalink
Normative: allow host exotic objects to reject private fields (#2807)
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkot authored and ljharb committed Aug 12, 2022
1 parent 63e56ae commit a705b0d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -6816,6 +6816,8 @@ <h1>
<dl class="header">
</dl>
<emu-alg>
1. If the host is a web browser, then
1. Perform ? HostEnsureCanAddPrivateElement(_O_).
1. Let _entry_ be PrivateElementFind(_O_, _P_).
1. If _entry_ is not ~empty~, throw a *TypeError* exception.
1. Append PrivateElement { [[Key]]: _P_, [[Kind]]: ~field~, [[Value]]: _value_ } to _O_.[[PrivateElements]].
Expand All @@ -6834,6 +6836,8 @@ <h1>
</dl>
<emu-alg>
1. Assert: _method_.[[Kind]] is either ~method~ or ~accessor~.
1. If the host is a web browser, then
1. Perform ? HostEnsureCanAddPrivateElement(_O_).
1. Let _entry_ be PrivateElementFind(_O_, _method_.[[Key]]).
1. If _entry_ is not ~empty~, throw a *TypeError* exception.
1. Append _method_ to _O_.[[PrivateElements]].
Expand All @@ -6844,6 +6848,25 @@ <h1>
</emu-note>
</emu-clause>

<emu-clause id="sec-hostensurecanaddprivateelement" type="host-defined abstract operation">
<h1>
HostEnsureCanAddPrivateElement (
_O_: an Object,
): either a normal completion containing ~unused~ or a throw completion
</h1>
<dl class="header">
<dt>description</dt>
<dd>It allows host environments to prevent the addition of private elements to particular host-defined exotic objects.</dd>
</dl>
<p>An implementation of HostEnsureCanAddPrivateElement must conform to the following requirements:</p>
<ul>
<li>If _O_ is not a host-defined exotic object, this abstract operation must return NormalCompletion(~unused~) and perform no other steps.</li>
<li>Any two calls of this abstract operation with the same argument must return the same kind of Completion Record.</li>
</ul>
<p>The default implementation of HostEnsureCanAddPrivateElement is to return NormalCompletion(~unused~).</p>
<p>This abstract operation is only invoked by ECMAScript hosts that are web browsers.</p>
</emu-clause>

<emu-clause id="sec-privateget" type="abstract operation">
<h1>
PrivateGet (
Expand Down

0 comments on commit a705b0d

Please sign in to comment.