- From: Domenic Denicola <notifications@github.com>
- Date: Thu, 07 Jan 2016 08:24:19 -0800
- To: whatwg/dom <dom@noreply.github.com>
- Message-ID: <whatwg/dom/pull/144/r49091589@github.com>
> @@ -8705,6 +8705,25 @@ associated <a for="/">element</a>'s > <p>Throws a <code>TypeError</code> exception if the associated attribute has no supported tokens defined. > </dl> > > +<p>The <a method for=DOMTokenList lt="supports()">supports()</a> method can be used to detect support for {{DOMTokenList}} tokens: > + > +<pre class=lang-javascript> > +var DOMTokenListSupports = function(tokenList, token) { > + if (!tokenList || !tokenList.supports) { > + return; > + } > + try { > + return tokenList.supports(token); > + } catch (e) { > + console.log("The DOMTokenList doesn't have a supported tokens list"); I'm not sure why we are catching this exception, and showing an example of people using `domTokenListSupports` on classList. We should not show examples of people doing wrong things, and definitely should not encourage them to write error-handling code for such programmer errors. I'd remove the try/catch, and maybe if you still want to let them know that classList will throw, you should just add a comment at the end of that line like "will throw since classList has no supported tokens list" --- Reply to this email directly or view it on GitHub: https://github.com/whatwg/dom/pull/144/files#r49091589
Received on Thursday, 7 January 2016 16:24:48 UTC