Skip to content

Commit

Permalink
Editorial: use abstract closure in Proxy.revocable (tc39#2439)
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkot authored and ljharb committed Jun 24, 2021
1 parent 5872981 commit 08d2018
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -40466,27 +40466,12 @@ <h1>Properties of the Proxy Constructor</h1>
<li>has the following properties:</li>
</ul>

<emu-clause id="sec-proxy.revocable">
<emu-clause id="sec-proxy.revocable" oldids="sec-proxy-revocation-functions">
<h1>Proxy.revocable ( _target_, _handler_ )</h1>
<p>The `Proxy.revocable` function is used to create a revocable Proxy object. When `Proxy.revocable` is called with arguments _target_ and _handler_, the following steps are taken:</p>
<emu-alg>
1. Let _p_ be ? ProxyCreate(_target_, _handler_).
1. Let _steps_ be the algorithm steps defined in <emu-xref href="#sec-proxy-revocation-functions" title></emu-xref>.
1. Let _length_ be the number of non-optional parameters of the function definition in <emu-xref href="#sec-proxy-revocation-functions" title></emu-xref>.
1. Let _revoker_ be ! CreateBuiltinFunction(_steps_, _length_, *""*, &laquo; [[RevocableProxy]] &raquo;).
1. Set _revoker_.[[RevocableProxy]] to _p_.
1. Let _result_ be ! OrdinaryObjectCreate(%Object.prototype%).
1. Perform ! CreateDataPropertyOrThrow(_result_, *"proxy"*, _p_).
1. Perform ! CreateDataPropertyOrThrow(_result_, *"revoke"*, _revoker_).
1. Return _result_.
</emu-alg>

<emu-clause id="sec-proxy-revocation-functions">
<h1>Proxy Revocation Functions</h1>
<p>A Proxy revocation function is an anonymous built-in function that has the ability to invalidate a specific Proxy object.</p>
<p>Each Proxy revocation function has a [[RevocableProxy]] internal slot.</p>
<p>When a Proxy revocation function is called, the following steps are taken:</p>
<emu-alg>
1. Let _revokerClosure_ be a new Abstract Closure with no parameters that captures nothing and performs the following steps when called:
1. Let _F_ be the active function object.
1. Let _p_ be _F_.[[RevocableProxy]].
1. If _p_ is *null*, return *undefined*.
Expand All @@ -40495,9 +40480,13 @@ <h1>Proxy Revocation Functions</h1>
1. Set _p_.[[ProxyTarget]] to *null*.
1. Set _p_.[[ProxyHandler]] to *null*.
1. Return *undefined*.
</emu-alg>
<p>The *"length"* property of a Proxy revocation function is *+0*<sub>𝔽</sub>.</p>
</emu-clause>
1. Let _revoker_ be ! CreateBuiltinFunction(_revokerClosure_, 0, *""*, &laquo; [[RevocableProxy]] &raquo;).
1. Set _revoker_.[[RevocableProxy]] to _p_.
1. Let _result_ be ! OrdinaryObjectCreate(%Object.prototype%).
1. Perform ! CreateDataPropertyOrThrow(_result_, *"proxy"*, _p_).
1. Perform ! CreateDataPropertyOrThrow(_result_, *"revoke"*, _revoker_).
1. Return _result_.
</emu-alg>
</emu-clause>
</emu-clause>
</emu-clause>
Expand Down

0 comments on commit 08d2018

Please sign in to comment.