.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / stylelint / lib / utils / isCustomElement.js
1 /* @flow */
2 "use strict";
3
4 const htmlTags = require("html-tags");
5 const keywordSets = require("../reference/keywordSets");
6 const mathMLTags = require("mathml-tag-names");
7 const svgTags = require("svg-tags");
8
9 /**
10  * Check whether a type selector is a custom element
11  */
12 module.exports = function(selector /*: string*/) /*: boolean*/ {
13   if (!/^[a-z]/.test(selector)) {
14     return false;
15   }
16
17   if (selector.indexOf("-") === -1) {
18     return false;
19   }
20
21   const selectorLowerCase = selector.toLowerCase();
22
23   if (selectorLowerCase !== selector) {
24     return false;
25   }
26   if (svgTags.indexOf(selectorLowerCase) !== -1) {
27     return false;
28   }
29   if (htmlTags.indexOf(selectorLowerCase) !== -1) {
30     return false;
31   }
32   if (keywordSets.nonStandardHtmlTags.has(selectorLowerCase)) {
33     return false;
34   }
35   if (mathMLTags.indexOf(selectorLowerCase) !== -1) {
36     return false;
37   }
38
39   return true;
40 };