Re: [dom] Added an example showing feature detection with supports() (#144)

> +
> +<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");
> +    }
> +};
> +
> +var linkSupportsToken = DOMTokenListSupports(document.createElement("link").relList, supportedToken);
> +var classListSupportsFoo = DOMTokenListSupports(document.createElement("div").classList, "foo"); // undefined + console.log
> +var linkSupportsFoo = DOMTokenListSupports(document.createElement("link").relList, "foo"); // false

I don't see a need for two examples for link. JavaScript developers know how to use variables.

---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/pull/144/files#r49091683

Received on Thursday, 7 January 2016 16:25:48 UTC