Skip to content

Commit fa0f1d3

Browse files
committed
feat(compiler): use isHtmlTags instead of html-tags
1 parent 1e4d1ac commit fa0f1d3

File tree

3 files changed

+30
-53
lines changed

3 files changed

+30
-53
lines changed

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,8 @@
137137
"@vue-vapor/runtime-vapor": "3.20240702.0-b44ca85",
138138
"@vue-vapor/shared": "3.20240702.0-b44ca85",
139139
"@vue-vapor/vue": "3.20240702.0-b44ca85",
140-
"html-tags": "^4.0.0",
141140
"magic-string-stack": "^0.1.1",
142141
"source-map-js": "^1.2.0",
143-
"svg-tags": "^1.0.0",
144142
"unplugin": "^1.11.0"
145143
},
146144
"devDependencies": {

pnpm-lock.yaml

Lines changed: 20 additions & 47 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/compiler/utils.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isGloballyAllowed, isString } from '@vue-vapor/shared'
1+
import { isGloballyAllowed, isString, makeMap } from '@vue-vapor/shared'
22
import {
33
type AttributeNode,
44
type DirectiveNode,
@@ -11,8 +11,6 @@ import {
1111
createSimpleExpression,
1212
isLiteralWhitelisted,
1313
} from '@vue-vapor/compiler-dom'
14-
import htmlTags, { type HtmlTags } from 'html-tags'
15-
import svgTags from 'svg-tags'
1614
import { type ParseResult, parseExpression } from '@babel/parser'
1715
import { EMPTY_EXPRESSION } from './transforms/utils'
1816
import type { TransformContext } from './transform'
@@ -236,13 +234,21 @@ export function resolveDirectiveNode(
236234
}
237235
}
238236

237+
// Copy from https://github.com/sindresorhus/html-tags/blob/main/html-tags.json
238+
export const isHtmlTags = makeMap(
239+
'a,abbr,address,area,article,aside,audio,b,base,bdi,bdo,blockquote,body,br,button,canvas,caption,cite,code,col,colgroup,data,datalist,dd,del,details,dfn,dialog,div,dl,dt,em,embed,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,i,iframe,img,input,ins,kbd,label,legend,li,link,main,map,mark,math,menu,menuitem,meta,meter,nav,noscript,object,ol,optgroup,option,output,p,param,picture,pre,progress,q,rb,rp,rt,rtc,ruby,s,samp,script,search,section,select,slot,small,source,span,strong,style,sub,summary,sup,svg,table,tbody,td,template,textarea,tfoot,th,thead,time,title,tr,track,u,ul,var,video,wbr',
240+
)
241+
// Copy from https://github.com/element-io/svg-tags/blob/master/lib/svg-tags.json
242+
export const isSvgTags = makeMap(
243+
'a,altGlyph,altGlyphDef,altGlyphItem,animate,animateColor,animateMotion,animateTransform,circle,clipPath,color-profile,cursor,defs,desc,ellipse,feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,feDistantLight,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,font,font-face,font-face-format,font-face-name,font-face-src,font-face-uri,foreignObject,g,glyph,glyphRef,hkern,image,line,linearGradient,marker,mask,metadata,missing-glyph,mpath,path,pattern,polygon,polyline,radialGradient,rect,script,set,stop,style,svg,switch,symbol,text,textPath,title,tref,tspan,use,view,vkern',
244+
)
239245
export function isComponentNode(node: Node): node is JSXElement {
240246
if (node.type !== 'JSXElement') return false
241247

242248
const { openingElement } = node
243249
if (openingElement.name.type === 'JSXIdentifier') {
244250
const name = openingElement.name.name
245-
return !htmlTags.includes(name as HtmlTags) && !svgTags.includes(name)
251+
return !isHtmlTags(name) && !isSvgTags(name)
246252
} else {
247253
return openingElement.name.type === 'JSXMemberExpression'
248254
}

0 commit comments

Comments
 (0)