14 lines
331 B
JavaScript
14 lines
331 B
JavaScript
|
// See https://stackoverflow.com/a/8533927
|
||
|
export function supportsSelector (selector) {
|
||
|
const style = document.createElement('style')
|
||
|
document.head.appendChild(style)
|
||
|
try {
|
||
|
style.sheet.insertRule(selector + '{}', 0)
|
||
|
} catch (e) {
|
||
|
return false
|
||
|
} finally {
|
||
|
document.head.removeChild(style)
|
||
|
}
|
||
|
return true
|
||
|
}
|