Skip to content

Commit

Permalink
Rewrite hasFeature() to be more practical
Browse files Browse the repository at this point in the history
  • Loading branch information
ayg committed Oct 16, 2012
1 parent ddd224e commit cdf7576
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 44 deletions.
75 changes: 54 additions & 21 deletions Overview.src.html
Expand Up @@ -4392,7 +4392,23 @@ <h4>Interface <code>DOMImplementation</code></h4>
<code title>title</code> element, unless the <var title>title</var> <code title>title</code> element, unless the <var title>title</var>
argument is omitted. argument is omitted.


<!-- hasFeature is obsolete --> <dt><code><var title>document</var> .
<span title=dom-Document-implementation>implementation</span> .
<span title=dom-DOMImplementation-hasFeature>hasFeature</span>(
<var title>feature</var>, <var title>version</var>)</code>

<dd>
<p>If <var title>feature</var> is an
<a href="http://www.w3.org/TR/SVG/feature.html">SVG feature</a> string,
returns whether that feature is supported. If <var title>feature</var> is
not the empty string, only returns true if the feature is supported as
defined in the given version of the SVG specification (e.g.,
"<code title>1.1</code>").

<p>If <var title>feature</var> is not an SVG feature, but rather some other
string like "<code title>HTML</code>" or
"<code title>flibbertigibbet</code>", always returns true. Thus, this method
is only useful for testing SVG features.
</dl> </dl>


<div class=impl> <div class=impl>
Expand Down Expand Up @@ -4524,30 +4540,47 @@ <h4>Interface <code>DOMImplementation</code></h4>
</ol> </ol>


<p>The <dfn title=dom-DOMImplementation-hasFeature><code>hasFeature(<var <p>The <dfn title=dom-DOMImplementation-hasFeature><code>hasFeature(<var
title>feature</var>, <var title>version</var>)</code></dfn> method must return title>feature</var>, <var title>version</var>)</code></dfn> method must run
true for any of (<var title>feature</var>, <var title>version</var>) tuples these steps:
listed below where <var title>feature</var> is an
<span>ASCII case-insensitive</span> and <var title>version</var> is a
<span>case-sensitive</span> match, or false otherwise.


<ul> <ol>
<li>("Core", "2.0") <li><p>If <var title>feature</var> begins with an
<li>("HTML", "1.0") <span>ASCII case-insensitive</span> match for one of the strings
<li>("HTML", "2.0") "<code title>http://www.w3.org/TR/SVG</code>",
<li>("XHTML", "1.0") "<code title>org.w3c.dom.svg</code>", or "<code title>org.w3c.svg</code>":
<li>("XHTML", "2.0")
<li>("XML", "1.0")
<li>("XML", "2.0")
</ul>


<!-- Chrome supports Core/1.0; Opera supports x/undefined --> <ol>
<li><p>If <var title>version</var> is the empty string:


<p class=XXX><a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=15555">Any others?</a> <ol>
<li><p>Return true if there is some SVG specification that defines a feature
that is an <span>ASCII case-insensitive</span> match for
<var title>feature</var>, and the user agent meets all the requirements of
that specification for that feature. Otherwise, return false.
</ol>

<li><p>Return true if <var title>version</var> is the version identifier for
a known SVG specification, and that specification defines a feature that is
an <span>ASCII case-insensitive</span> match for <var title>feature</var>,
and the user agent meets all the requirements of that specification for that
feature. Otherwise, return false.

<p class=XXX>What happens if a feature is only defined in 1.1 but the version
string passed is 1.0? Most UAs return true in this case too, but do we want
to spec that?
</ol>

<li><p>Return true.
</ol>


<p class=note>The <p class=note><code title=dom-DOMImplementation-hasFeature>hasFeature()</code>
<code title=dom-DOMImplementation-hasFeature>hasFeature()</code> is a badly originally would report whether the user agent claimed to support a given DOM
designed method (features are notoriously unreliable and imprecise) that is feature, but experience proved it was not nearly as reliable or granular as
now effectively obsolete and only needs to be supported for deployed content. simply checking whether the desired interfaces, attributes, or methods existed.
As such, it should no longer be used, but continues to exist (and simply
returns true) so that old pages don't stop working. SVG features are a
separate mechanism that reused the existing method, so they continue to work as
a special case.


</div> </div>


Expand Down
79 changes: 56 additions & 23 deletions dom-core.html
Expand Up @@ -8,7 +8,7 @@


<div class="head"> <div class="head">
<h1>DOM</h1> <h1>DOM</h1>
<h2 class="no-num no-toc" id="living-standard-—-last-updated-12-october-2012">Living Standard — Last Updated 12 October 2012</h2> <h2 class="no-num no-toc" id="living-standard-—-last-updated-16-october-2012">Living Standard — Last Updated 16 October 2012</h2>


<dl> <dl>
<dt>This Version: <dt>This Version:
Expand Down Expand Up @@ -39,7 +39,7 @@ <h2 class="no-num no-toc" id="living-standard-—-last-updated-12-october-2012">
<p class="copyright"><a href="http://creativecommons.org/publicdomain/zero/1.0/" rel="license"><img alt="CC0" src="http://i.creativecommons.org/p/zero/1.0/80x15.png"></a> <p class="copyright"><a href="http://creativecommons.org/publicdomain/zero/1.0/" rel="license"><img alt="CC0" src="http://i.creativecommons.org/p/zero/1.0/80x15.png"></a>
To the extent possible under law, the editors have waived all copyright and To the extent possible under law, the editors have waived all copyright and
related or neighboring rights to this work. In addition, as of related or neighboring rights to this work. In addition, as of
12 October 2012, the editors have made this specification available 16 October 2012, the editors have made this specification available
under the under the
<a href="http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0" rel="license">Open Web Foundation Agreement Version 1.0</a>, <a href="http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0" rel="license">Open Web Foundation Agreement Version 1.0</a>,
which is available at which is available at
Expand Down Expand Up @@ -4442,7 +4442,23 @@ <h4 id="interface-domimplementation"><span class="secno">5.4.1 </span>Interface
<code title="">title</code> element, unless the <var title="">title</var> <code title="">title</code> element, unless the <var title="">title</var>
argument is omitted. argument is omitted.


<!-- hasFeature is obsolete --> <dt><code><var title="">document</var> .
<a href="#dom-document-implementation" title="dom-Document-implementation">implementation</a> .
<a href="#dom-domimplementation-hasfeature" title="dom-DOMImplementation-hasFeature">hasFeature</a>(
<var title="">feature</var>, <var title="">version</var>)</code>

<dd>
<p>If <var title="">feature</var> is an
<a href="http://www.w3.org/TR/SVG/feature.html">SVG feature</a> string,
returns whether that feature is supported. If <var title="">feature</var> is
not the empty string, only returns true if the feature is supported as
defined in the given version of the SVG specification (e.g.,
"<code title="">1.1</code>").

<p>If <var title="">feature</var> is not an SVG feature, but rather some other
string like "<code title="">HTML</code>" or
"<code title="">flibbertigibbet</code>", always returns true. Thus, this method
is only useful for testing SVG features.
</dl> </dl>


<div class="impl"> <div class="impl">
Expand Down Expand Up @@ -4572,30 +4588,47 @@ <h4 id="interface-domimplementation"><span class="secno">5.4.1 </span>Interface
<li><p>Return <var title="">doc</var>. <li><p>Return <var title="">doc</var>.
</ol> </ol>


<p>The <dfn id="dom-domimplementation-hasfeature" title="dom-DOMImplementation-hasFeature"><code>hasFeature(<var title="">feature</var>, <var title="">version</var>)</code></dfn> method must return <p>The <dfn id="dom-domimplementation-hasfeature" title="dom-DOMImplementation-hasFeature"><code>hasFeature(<var title="">feature</var>, <var title="">version</var>)</code></dfn> method must run
true for any of (<var title="">feature</var>, <var title="">version</var>) tuples these steps:
listed below where <var title="">feature</var> is an
<a href="#ascii-case-insensitive">ASCII case-insensitive</a> and <var title="">version</var> is a
<a href="#case-sensitive">case-sensitive</a> match, or false otherwise.


<ul> <ol>
<li>("Core", "2.0") <li><p>If <var title="">feature</var> begins with an
<li>("HTML", "1.0") <a href="#ascii-case-insensitive">ASCII case-insensitive</a> match for one of the strings
<li>("HTML", "2.0") "<code title="">http://www.w3.org/TR/SVG</code>",
<li>("XHTML", "1.0") "<code title="">org.w3c.dom.svg</code>", or "<code title="">org.w3c.svg</code>":
<li>("XHTML", "2.0")
<li>("XML", "1.0") <ol>
<li>("XML", "2.0") <li><p>If <var title="">version</var> is the empty string:
</ul>
<ol>
<li><p>Return true if there is some SVG specification that defines a feature
that is an <a href="#ascii-case-insensitive">ASCII case-insensitive</a> match for
<var title="">feature</var>, and the user agent meets all the requirements of
that specification for that feature. Otherwise, return false.
</ol>


<!-- Chrome supports Core/1.0; Opera supports x/undefined --> <li><p>Return true if <var title="">version</var> is the version identifier for
a known SVG specification, and that specification defines a feature that is
an <a href="#ascii-case-insensitive">ASCII case-insensitive</a> match for <var title="">feature</var>,
and the user agent meets all the requirements of that specification for that
feature. Otherwise, return false.


<p class="XXX"><a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=15555">Any others?</a> <p class="XXX">What happens if a feature is only defined in 1.1 but the version
string passed is 1.0? Most UAs return true in this case too, but do we want
to spec that?
</ol>

<li><p>Return true.
</ol>


<p class="note">The <p class="note"><code title="dom-DOMImplementation-hasFeature"><a href="#dom-domimplementation-hasfeature">hasFeature()</a></code>
<code title="dom-DOMImplementation-hasFeature"><a href="#dom-domimplementation-hasfeature">hasFeature()</a></code> is a badly originally would report whether the user agent claimed to support a given DOM
designed method (features are notoriously unreliable and imprecise) that is feature, but experience proved it was not nearly as reliable or granular as
now effectively obsolete and only needs to be supported for deployed content. simply checking whether the desired interfaces, attributes, or methods existed.
As such, it should no longer be used, but continues to exist (and simply
returns true) so that old pages don't stop working. SVG features are a
separate mechanism that reused the existing method, so they continue to work as
a special case.


</div> </div>


Expand Down

0 comments on commit cdf7576

Please sign in to comment.