stylelint
Version:
A mighty CSS linter that helps you avoid errors and enforce conventions.
25 lines (20 loc) • 562 B
JavaScript
import { hyphenContainingTypeSelectors } from '../reference/selectors.mjs';
/**
* Check whether a type selector is a custom element
*
* @see https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
* @param {string} selector
* @returns {boolean}
*/
export default function isCustomElement(selector) {
if (!/^[a-z]/.test(selector)) {
return false;
}
if (!selector.includes('-')) {
return false;
}
if (selector.toLowerCase() !== selector) {
return false;
}
return !hyphenContainingTypeSelectors.has(selector);
}