Forked from igrigorik/domtokenlist_feature_detection.js
Created
July 29, 2019 19:19
-
-
Save sitedata/d448f59ac9668247ba3d471670f7f0e0 to your computer and use it in GitHub Desktop.
DOMTokenList supports() example for Preload
This file contains 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 characters
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"); | |
} | |
} | |
}; | |
// test if preload is supported | |
var linkSupportsPreload = DOMTokenListSupports(document.createElement("link").relList, "preload"); | |
if (linkSupportsPreload) { | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment