Created
December 3, 2015 17:12
-
-
Save yoavweiss/2b6a5fdb991be72a1f79 to your computer and use it in GitHub Desktop.
DOMTokenList feature detection
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 tokenListSupports = function(tokenList, token) { | |
if (!tokenList || !tokenList.supports) { | |
return false; | |
} | |
try { | |
return tokenList.supports(token); | |
} catch (e) { | |
if (e instanceof TypeError) { | |
console.log("The DOMTokenList doesn't have a supported tokens list"); | |
} else { | |
console.log("That shouldn't have happened"); | |
} | |
} | |
}; | |
var linkSupports = function(token) { | |
return tokenListSupports(document.createElement("link").relList); | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment