Permalink
Browse files

Add support for thenable.

  • Loading branch information...
1 parent 1268f9e commit 77c556982412383cf27653bbbeb41c620aee62ee @annevk annevk committed Mar 28, 2013
Showing with 96 additions and 16 deletions.
  1. +48 −8 Overview.src.html
  2. +48 −8 dom-core.html
View
@@ -688,8 +688,9 @@ <h2 class=no-num>Goals</h2>
<span title=concept-resolver-resolve>resolve</span> with <var title>result</var> and
the <i title>synchronous flag</i> set.
- <p class=note>The <i title>synchronous flag</i> is ignored if <var title>result</var>
- is a <span title=concept-future>future</span>.
+ <p class=note>The <i title>synchronous flag</i> will be ignored if
+ <var title>result</var> is a <span title=concept-future>future</span> or has a
+ non-throwing <code title>then</code> method.
</ol>
<li><p>Discard <var title>handler</var>.
@@ -708,6 +709,10 @@ <h2 class=no-num>Goals</h2>
and optionally a <i title>synchronous flag</i>, and runs these steps:
<ol>
+ <!--
+ <li><p>If the <span>resolved flag</span> is set, terminate these steps.
+ can never happen -->
+
<li><p>Let <var title>future</var> be its associated
<span title=concept-future>future</span>.
@@ -736,6 +741,9 @@ <h2 class=no-num>Goals</h2>
and optionally a <i title>synchronous flag</i>, and runs these steps:
<ol>
+ <li><p>If the <span>resolved flag</span> is set, terminate these steps.
+ <!-- can happen via anonymous callbacks -->
+
<li><p>Let <var title>future</var> be its associated
<span title=concept-future>future</span>.
@@ -764,9 +772,12 @@ <h2 class=no-num>Goals</h2>
and optionally a <i title>synchronous flag</i>, and runs these steps:
<ol>
+ <li><p>If the <span>resolved flag</span> is set, terminate these steps.
+ <!-- can happen via anonymous callbacks -->
+
<li>
<p>If <var title>value</var> is a <span title=concept-future>future</span>, run these
- substeps:
+ substeps and then terminate these steps:
<!-- JS branding? -->
<ol>
@@ -784,13 +795,42 @@ <h2 class=no-num>Goals</h2>
<li><p><span title=concept-future-append>Append</span> <var title>accept</var> and
<var title>reject</var> to <var title>value</var>.
-
</ol>
- <p class=note>The <i title>synchronous flag</i> is ignored here as the
- <span title=concept-future>future</span> could have changed
- <span title=concept-future-state>state</span> in the same
- <span data-anolis-spec=html title=concept-task>task</span>.
+ <li>
+ <p>Let <var title>then</var> be null.
+
+ <p class=note>Starting here the algorithm is described in terms of the JavaScript
+ specification. (Or ECMAScript, if you feel that is a more suitable name.)
+
+ <li><p>If <var title>value</var> is a JavaScript Object, set <var title>then</var> to
+ the result of calling the JavaScript <code title>[[Get]]</code> internal method of
+ <var title>value</var> with property name <code title>then</code>.
+
+ <li><p>If calling the <code title>[[Get]]</code> internal method threw an exception, run
+ <span title=concept-resolver-reject>reject</span> with the thrown exception and the
+ <i title>synchronous flag</i> if set, and then terminate these steps.
+
+ <li>
+ <p>If JavaScript IsCallable <var title>then</var>, then run these substeps:
+
+ <ol>
+ <li><p>Let <var title>accept</var> be a JavaScript <code title>Function</code> Object
+ which when called invokes <span title=concept-resolver-accept>accept</span> with the
+ first argument passed and with <code title>undefined</code> if no arguments are passed.
+
+ <li><p>Let <var title>reject</var> be a JavaScript <code title>Function</code> Object
+ which when called invokes <span title=concept-resolver-reject>reject</span> with the
+ first argument passed and with <code title>undefined</code> if no arguments are passed.
+
+ <li><p>Call the JavaScript <code title>[[Call]]</code> internal method of
+ <var title>then</var> with <b title>this</b> value <var title>value</var> and
+ <var title>accept</var> and <var title>reject</var> as arguments.
+
+ <li><p>If calling the <code title>[[Call]]</code> internal method threw an exception,
+ run <span title=concept-resolver-reject>reject</span> with the thrown exception and the
+ <i title>synchronous flag</i> if set.
+ </ol>
<li><p>Otherwise, run <span title=concept-resolver-accept>accept</span> with
<var title>value</var> and the <i title>synchronous flag</i> if set.
View
@@ -766,8 +766,9 @@ <h3 id="futures-model"><span class="secno">4.2 </span>Futures Model</h3>
<a href="#concept-resolver-resolve" title="concept-resolver-resolve">resolve</a> with <var title="">result</var> and
the <i title="">synchronous flag</i> set.
- <p class="note">The <i title="">synchronous flag</i> is ignored if <var title="">result</var>
- is a <a href="#concept-future" title="concept-future">future</a>.
+ <p class="note">The <i title="">synchronous flag</i> will be ignored if
+ <var title="">result</var> is a <a href="#concept-future" title="concept-future">future</a> or has a
+ non-throwing <code title="">then</code> method.
</ol>
<li><p>Discard <var title="">handler</var>.
@@ -786,6 +787,10 @@ <h3 id="futures-model"><span class="secno">4.2 </span>Futures Model</h3>
and optionally a <i title="">synchronous flag</i>, and runs these steps:
<ol>
+ <!--
+ <li><p>If the <span>resolved flag</span> is set, terminate these steps.
+ can never happen -->
+
<li><p>Let <var title="">future</var> be its associated
<a href="#concept-future" title="concept-future">future</a>.
@@ -814,6 +819,9 @@ <h3 id="futures-model"><span class="secno">4.2 </span>Futures Model</h3>
and optionally a <i title="">synchronous flag</i>, and runs these steps:
<ol>
+ <li><p>If the <a href="#resolved-flag">resolved flag</a> is set, terminate these steps.
+ <!-- can happen via anonymous callbacks -->
+
<li><p>Let <var title="">future</var> be its associated
<a href="#concept-future" title="concept-future">future</a>.
@@ -842,9 +850,12 @@ <h3 id="futures-model"><span class="secno">4.2 </span>Futures Model</h3>
and optionally a <i title="">synchronous flag</i>, and runs these steps:
<ol>
+ <li><p>If the <a href="#resolved-flag">resolved flag</a> is set, terminate these steps.
+ <!-- can happen via anonymous callbacks -->
+
<li>
<p>If <var title="">value</var> is a <a href="#concept-future" title="concept-future">future</a>, run these
- substeps:
+ substeps and then terminate these steps:
<!-- JS branding? -->
<ol>
@@ -862,13 +873,42 @@ <h3 id="futures-model"><span class="secno">4.2 </span>Futures Model</h3>
<li><p><a href="#concept-future-append" title="concept-future-append">Append</a> <var title="">accept</var> and
<var title="">reject</var> to <var title="">value</var>.
-
</ol>
- <p class="note">The <i title="">synchronous flag</i> is ignored here as the
- <a href="#concept-future" title="concept-future">future</a> could have changed
- <a href="#concept-future-state" title="concept-future-state">state</a> in the same
- <a class="external" data-anolis-spec="html" href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#concept-task" title="concept-task">task</a>.
+ <li>
+ <p>Let <var title="">then</var> be null.
+
+ <p class="note">Starting here the algorithm is described in terms of the JavaScript
+ specification. (Or ECMAScript, if you feel that is a more suitable name.)
+
+ <li><p>If <var title="">value</var> is a JavaScript Object, set <var title="">then</var> to
+ the result of calling the JavaScript <code title="">[[Get]]</code> internal method of
+ <var title="">value</var> with property name <code title="">then</code>.
+
+ <li><p>If calling the <code title="">[[Get]]</code> internal method threw an exception, run
+ <a href="#concept-resolver-reject" title="concept-resolver-reject">reject</a> with the thrown exception and the
+ <i title="">synchronous flag</i> if set, and then terminate these steps.
+
+ <li>
+ <p>If JavaScript IsCallable <var title="">then</var>, then run these substeps:
+
+ <ol>
+ <li><p>Let <var title="">accept</var> be a JavaScript <code title="">Function</code> Object
+ which when called invokes <a href="#concept-resolver-accept" title="concept-resolver-accept">accept</a> with the
+ first argument passed and with <code title="">undefined</code> if no arguments are passed.
+
+ <li><p>Let <var title="">reject</var> be a JavaScript <code title="">Function</code> Object
+ which when called invokes <a href="#concept-resolver-reject" title="concept-resolver-reject">reject</a> with the
+ first argument passed and with <code title="">undefined</code> if no arguments are passed.
+
+ <li><p>Call the JavaScript <code title="">[[Call]]</code> internal method of
+ <var title="">then</var> with <b title="">this</b> value <var title="">value</var> and
+ <var title="">accept</var> and <var title="">reject</var> as arguments.
+
+ <li><p>If calling the <code title="">[[Call]]</code> internal method threw an exception,
+ run <a href="#concept-resolver-reject" title="concept-resolver-reject">reject</a> with the thrown exception and the
+ <i title="">synchronous flag</i> if set.
+ </ol>
<li><p>Otherwise, run <a href="#concept-resolver-accept" title="concept-resolver-accept">accept</a> with
<var title="">value</var> and the <i title="">synchronous flag</i> if set.

0 comments on commit 77c5569

Please sign in to comment.