Skip to content

Commit

Permalink
Fix #93: use less loops
Browse files Browse the repository at this point in the history
This changes the exception order for DOMTokenList’s add() and remove(),
but this is in line with implementations so all is good.
  • Loading branch information
annevk committed Nov 11, 2015
1 parent eda3dcd commit 244f66f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 12 deletions.
22 changes: 16 additions & 6 deletions dom.bs
Expand Up @@ -8770,10 +8770,15 @@ invoked, must run these steps:
method, when invoked, must run these steps:

<ol>
<li><p>If one of <var>tokens</var> is the empty string, <a>throw</a> a {{SyntaxError}} exception.
<li>
<p>For each <var>token</var> in <var>tokens</var>, run these substeps:

<li><p>If one of <var>tokens</var> contains any <a>ASCII whitespace</a>, then <a>throw</a> an
{{InvalidCharacterError}} exception.
<ol>
<li><p>If <var>token</var> is the empty string, <a>throw</a> a {{SyntaxError}} exception.

<li><p>If <var>token</var> contains any <a>ASCII whitespace</a>, <a>throw</a> an
{{InvalidCharacterError}} exception.
</ol>

<li>Let <var>valid</var> be true.

Expand All @@ -8791,10 +8796,15 @@ method, when invoked, must run these steps:
method, when invoked, must run these steps:

<ol>
<li><p>If one of <var>tokens</var> is the empty string, <a>throw</a> a {{SyntaxError}} exception.
<li>
<p>For each <var>token</var> in <var>tokens</var>, run these substeps:

<li><p>If one of <var>tokens</var> contains any <a>ASCII whitespace</a>, then <a>throw</a> an
{{InvalidCharacterError}} exception.
<ol>
<li><p>If <var>token</var> is the empty string, <a>throw</a> a {{SyntaxError}} exception.

<li><p>If <var>token</var> contains any <a>ASCII whitespace</a>, <a>throw</a> an
{{InvalidCharacterError}} exception.
</ol>

<li><p>For each <var>token</var> in <var>tokens</var>, remove <var>token</var> from <a>tokens</a>.

Expand Down
20 changes: 14 additions & 6 deletions dom.html
Expand Up @@ -4107,9 +4107,13 @@ <h3 class="heading settled" data-level="7.1" id="interface-domtokenlist"><span c
<p>The <dfn class="idl-code" data-dfn-for="DOMTokenList" data-dfn-type="method" data-export="" data-lt="add(tokens)|add()" id="dom-domtokenlist-add"><code>add(<var>tokens</var>…)</code><a class="self-link" href="#dom-domtokenlist-add"></a></dfn> method, when invoked, must run these steps: </p>
<ol>
<li>
<p>If one of <var>tokens</var> is the empty string, <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">throw</a> a <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#syntaxerror">SyntaxError</a></code> exception. </p>
<li>
<p>If one of <var>tokens</var> contains any <a data-link-type="dfn" href="https://encoding.spec.whatwg.org/#ascii-whitespace">ASCII whitespace</a>, then <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">throw</a> an <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#invalidcharactererror">InvalidCharacterError</a></code> exception. </p>
<p>For each <var>token</var> in <var>tokens</var>, run these substeps: </p>
<ol>
<li>
<p>If <var>token</var> is the empty string, <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">throw</a> a <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#syntaxerror">SyntaxError</a></code> exception. </p>
<li>
<p>If <var>token</var> contains any <a data-link-type="dfn" href="https://encoding.spec.whatwg.org/#ascii-whitespace">ASCII whitespace</a>, <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">throw</a> an <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#invalidcharactererror">InvalidCharacterError</a></code> exception. </p>
</ol>
<li>Let <var>valid</var> be true.
<li>
<p>For each <var>token</var> in <var>tokens</var>, in given order, that is not in <a data-link-type="dfn" href="#concept-dtl-tokens">tokens</a>, run <a data-link-type="dfn" href="#concept-domtokenlist-validation">validation steps</a> with <var>token</var>. If the return value is false,
Expand All @@ -4122,9 +4126,13 @@ <h3 class="heading settled" data-level="7.1" id="interface-domtokenlist"><span c
<p>The <dfn class="idl-code" data-dfn-for="DOMTokenList" data-dfn-type="method" data-export="" data-lt="remove(tokens)|remove()" id="dom-domtokenlist-remove"><code>remove(<var>tokens</var>…)</code><a class="self-link" href="#dom-domtokenlist-remove"></a></dfn> method, when invoked, must run these steps: </p>
<ol>
<li>
<p>If one of <var>tokens</var> is the empty string, <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">throw</a> a <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#syntaxerror">SyntaxError</a></code> exception. </p>
<li>
<p>If one of <var>tokens</var> contains any <a data-link-type="dfn" href="https://encoding.spec.whatwg.org/#ascii-whitespace">ASCII whitespace</a>, then <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">throw</a> an <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#invalidcharactererror">InvalidCharacterError</a></code> exception. </p>
<p>For each <var>token</var> in <var>tokens</var>, run these substeps: </p>
<ol>
<li>
<p>If <var>token</var> is the empty string, <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">throw</a> a <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#syntaxerror">SyntaxError</a></code> exception. </p>
<li>
<p>If <var>token</var> contains any <a data-link-type="dfn" href="https://encoding.spec.whatwg.org/#ascii-whitespace">ASCII whitespace</a>, <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-throw">throw</a> an <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#invalidcharactererror">InvalidCharacterError</a></code> exception. </p>
</ol>
<li>
<p>For each <var>token</var> in <var>tokens</var>, remove <var>token</var> from <a data-link-type="dfn" href="#concept-dtl-tokens">tokens</a>. </p>
<li>
Expand Down

0 comments on commit 244f66f

Please sign in to comment.