isCustomElement.cjs 793 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // NOTICE: This file is generated by Rollup. To modify it,
  2. // please instead edit the ESM counterpart and rebuild with Rollup (npm run build).
  3. 'use strict';
  4. const svgTags = require('svg-tags');
  5. const mathMLTags = require('./mathMLTags.cjs');
  6. /**
  7. * Check whether a type selector is a custom element
  8. *
  9. * @param {string} selector
  10. * @returns {boolean}
  11. */
  12. function isCustomElement(selector) {
  13. if (!/^[a-z]/.test(selector)) {
  14. return false;
  15. }
  16. if (!selector.includes('-')) {
  17. return false;
  18. }
  19. const selectorLowerCase = selector.toLowerCase();
  20. if (selectorLowerCase !== selector) {
  21. return false;
  22. }
  23. if (svgTags.includes(selectorLowerCase)) {
  24. return false;
  25. }
  26. if (mathMLTags.includes(selectorLowerCase)) {
  27. return false;
  28. }
  29. return true;
  30. }
  31. module.exports = isCustomElement;