Forked from yoavweiss/domtokenlist_feature_detection.js
Last active
June 21, 2023 16:57
-
-
Save igrigorik/a02f2359f3bc50ca7a9c to your computer and use it in GitHub Desktop.
Revisions
-
igrigorik revised this gist
Jan 26, 2016 . No changes.There are no files selected for viewing
-
igrigorik renamed this gist
Jan 26, 2016 . 1 changed file with 5 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,6 +13,8 @@ } }; // test if preload is supported var linkSupportsPreload = DOMTokenListSupports(document.createElement("link").relList, "preload"); if (linkSupportsPreload) { // ... } -
yoavweiss renamed this gist
Jan 26, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
yoavweiss revised this gist
Jan 22, 2016 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,5 +14,5 @@ var DOMTokenListSupports = function(tokenList, token) { }; var linkSupportsPreload = DOMTokenListSupports(document.createElement("link").relList, "preload"); // true var classListSupportsFoobar = DOMTokenListSupports(document.createElement("div").classList, "foobar"); // undefined + console.log var linkSupportsFoobar = DOMTokenListSupports(document.createElement("link").relList, "foobar"); // false -
yoavweiss created this gist
Jan 22, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ var DOMTokenListSupports = function(tokenList, token) { if (!tokenList || !tokenList.supports) { return; } try { return tokenList.supports(token); } catch (e) { if (e instanceof TypeError) { console.log("The DOMTokenList doesn't have a supported tokens list"); } else { console.error("That shouldn't have happened"); } } }; var linkSupportsPreload = DOMTokenListSupports(document.createElement("link").relList, "preload"); // true var classListSupportsWhatever = DOMTokenListSupports(document.createElement("div").classList, "whatever"); // undefined + console.log var linkSupportsWhatever = DOMTokenListSupports(document.createElement("link").relList, "whatever"); // false