Browse Source

es6 proxy guide draft

pull/7/head
Sami Vaarala 11 years ago
parent
commit
d94625cddd
  1. 38
      website/guide/es6features.html

38
website/guide/es6features.html

@ -1,23 +1,47 @@
<h1 id="es6features">Ecmascript E6 features</h1> <h1 id="es6features">Ecmascript E6 features</h1>
<p>This section describes the small set of features Duktape borrows from the <p>This section describes the small set of features Duktape borrows from the
<a href="https://people.mozilla.org/~jorendorff/es6-draft.html">current ES6 draft</a>. <a href="https://people.mozilla.org/~jorendorff/es6-draft.html">current ES6 draft</a>
These features are not fully compliant; the intent is to minimize custom features ("Version: Rev 23, April 5, 2014 Draft"). These features are not fully compliant;
and to align with the coming ES6 specification.</p> the intent is to minimize custom features and to align with the coming ES6 specification.</p>
<h2 id="es6-proto">Object.setPrototypeOf and Object.prototype.__proto__</h2> <h2 id="es6-proto">Object.setPrototypeOf and Object.prototype.__proto__</h2>
<p><a href="https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.setprototypeof">Object.setPrototypeOf</a> <p><a href="https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.setprototypeof">Object.setPrototypeOf</a>
allows user to set the internal prototype of an object which is not supported in allows user to set the internal prototype of an object which is not supported in
Ecmascript E5. The Ecmascript E6 draft also provides Ecmascript E5. The Ecmascript E6 draft also provides
<a href="https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.__proto__">Object.prototype.__proto__</a> <a href="https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.__proto__">Object.prototype.__proto__</a>,
which is an accessor property (setter/getter) which provides the same functionality an accessor property (setter/getter) which provides the same functionality
but is compatible with existing code base which has relied on a non-standard but is compatible with existing code base which has relied on a non-standard
<code>__proto__</code> property for a while. Duktape does not support the <code>__proto__</code> property for a while. Duktape does not support the
<a href="https://people.mozilla.org/~jorendorff/es6-draft.html#sec-__proto___-property-names-in-object-initializers">__proto__ property name in an object initializer</a>.</p> <a href="https://people.mozilla.org/~jorendorff/es6-draft.html#sec-__proto___-property-names-in-object-initializers">__proto__ property name in an object initializer</a>.</p>
<p>These custom features can be disabled with feature options.</p> <p>These custom features can be disabled with the feature options
<code>DUK_OPT_NO_OBJECT_ES6_SETPROTOTYPEOF</code> and
<code>DUK_OPT_NO_OBJECT_ES6_PROTO_PROPERTY</code>.</p>
<h2 id="es6-proxy">Proxy object (subset)</h2> <h2 id="es6-proxy">Proxy object (subset)</h2>
<p>FIXME.</p> <p>The Ecmascript E6 <code>Proxy</code> object allows property virtualization
and fine-grained access control for accessing an underlying plain object.
Duktape implements a strict subset of the <code>Proxy</code> object from the
ES6 draft (Rev 23).</p>
<p>Limitations include:</p>
<ul>
<li>Limited to <code>get</code>, <code>set</code>, <code>deleteProperty</code>
handler methods; ES6 draft allows a lot more, e.g. to interact with
properties being called or constructed, enumeration, etc. This causes
odd behavior if you enumerate a proxy object, call
<code>Object.defineProperty()</code> with the proxy object as an argument,
etc.</li>
<li>Proxy revocation feature of ES6 draft is not supported.</li>
<li>The target and handler objects given to <code>new Proxy()</code> cannot
be proxy objects themselves. ES6 poses no such limitation, but Duktape
enforces it to simplify the internal implementation.</li>
<li>As ES6 is still in a draft phase so the subset implemented by Duktape
may not be forwards compatible.</li>
</ul>
<p>This custom feature can be disabled with the feature option
<code>DUK_OPT_NO_ES6_PROXY</code>.</p>

Loading…
Cancel
Save