Skip to content

Commit c248c96

Browse files
committed
Add isMathMLElementName
1 parent e1ad64d commit c248c96

File tree

5 files changed

+1294
-236
lines changed

5 files changed

+1294
-236
lines changed

lib/utils/html-elements.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

lib/utils/index.js

Lines changed: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
// Helpers
1010
// ------------------------------------------------------------------------------
1111

12-
const HTML_ELEMENT_NAMES = new Set(require('./html-elements.json'))
13-
const SVG_ELEMENT_NAMES = new Set(require('./svg-elements.json'))
14-
const VOID_ELEMENT_NAMES = new Set(require('./void-elements.json'))
12+
const HTML_TAG_NAMES = new Set(require('html-tag-names'))
13+
const SVG_TAG_NAMES = new Set(require('svg-tag-names'))
14+
const MATHML_TAG_NAMES = new Set(require('mathml-tag-names'))
15+
const VOID_TAG_NAMES = new Set(require('./void-elements.json'))
1516
const assert = require('assert')
1617

1718
// ------------------------------------------------------------------------------
@@ -67,8 +68,8 @@ module.exports = {
6768
assert(node && node.type === 'VElement')
6869

6970
return (
70-
node.parent.type === 'Program' ||
71-
node.parent.parent.type === 'Program'
71+
node.parent.type === 'Program' ||
72+
node.parent.parent.type === 'Program'
7273
)
7374
},
7475

@@ -194,53 +195,64 @@ module.exports = {
194195
)
195196
},
196197

197-
/**
198-
* Check whether the given node is a custom component or not.
199-
* @param {ASTNode} node The start tag node to check.
200-
* @returns {boolean} `true` if the node is a custom component.
201-
*/
198+
/**
199+
* Check whether the given node is a custom component or not.
200+
* @param {ASTNode} node The start tag node to check.
201+
* @returns {boolean} `true` if the node is a custom component.
202+
*/
202203
isCustomComponent (node) {
203204
assert(node && node.type === 'VStartTag')
204205

205206
const name = node.id.name
206207
return (
207-
!(this.isHtmlElementName(name) || this.isSvgElementName(name)) ||
208-
this.hasAttribute(node, 'is') ||
209-
this.hasDirective(node, 'bind', 'is')
208+
!(this.isHtmlElementName(name) || this.isSvgElementName(name) || this.isMathMLElementName(name)) ||
209+
this.hasAttribute(node, 'is') ||
210+
this.hasDirective(node, 'bind', 'is')
210211
)
211212
},
212213

213-
/**
214-
* Check whether the given name is a HTML element name or not.
215-
* @param {string} name The name to check.
216-
* @returns {boolean} `true` if the name is a HTML element name.
217-
*/
214+
/**
215+
* Check whether the given name is a HTML element name or not.
216+
* @param {string} name The name to check.
217+
* @returns {boolean} `true` if the name is a HTML element name.
218+
*/
218219
isHtmlElementName (name) {
219220
assert(typeof name === 'string')
220221

221-
return HTML_ELEMENT_NAMES.has(name.toLowerCase())
222+
return HTML_TAG_NAMES.has(name.toLowerCase())
222223
},
223224

224-
/**
225-
* Check whether the given name is a SVG element name or not.
226-
* @param {string} name The name to check.
227-
* @returns {boolean} `true` if the name is a SVG element name.
228-
*/
225+
/**
226+
* Check whether the given name is a SVG element name or not.
227+
* @param {string} name The name to check.
228+
* @returns {boolean} `true` if the name is a SVG element name.
229+
*/
229230
isSvgElementName (name) {
230231
assert(typeof name === 'string')
231232

232-
return SVG_ELEMENT_NAMES.has(name.toLowerCase())
233+
return SVG_TAG_NAMES.has(name.toLowerCase())
233234
},
234235

235-
/**
236-
* Check whether the given name is a void element name or not.
237-
* @param {string} name The name to check.
238-
* @returns {boolean} `true` if the name is a void element name.
239-
*/
236+
/**
237+
* Check whether the given name is a MathML element name or not.
238+
* @param {string} name The name to check.
239+
* @returns {boolean} `true` if the name is a HTML element name.
240+
*/
241+
isMathMLElementName (name) {
242+
assert(typeof name === 'string')
243+
244+
return MATHML_TAG_NAMES.has(name.toLowerCase())
245+
},
246+
247+
/**
248+
* Check whether the given name is a void element name or not.
249+
* @param {string} name The name to check.
250+
* @returns {boolean} `true` if the name is a void element name.
251+
*/
240252
isVoidElementName (name) {
241253
assert(typeof name === 'string')
242254

243-
return VOID_ELEMENT_NAMES.has(name.toLowerCase())
255+
return VOID_TAG_NAMES.has(name.toLowerCase())
244256
},
245257

246258
/**

lib/utils/svg-elements.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)