Skip to content

Commit f3e7dd5

Browse files
committed
Support SVG 2 elements, using @vue/shared to ensure consistent behavior with vue
1 parent 5e77d5d commit f3e7dd5

File tree

3 files changed

+9
-24
lines changed

3 files changed

+9
-24
lines changed

packages/babel-plugin-jsx/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,13 @@
3131
"@babel/types": "^7.26.9",
3232
"@vue/babel-helper-vue-transform-on": "workspace:*",
3333
"@vue/babel-plugin-resolve-type": "workspace:*",
34-
"html-tags": "^3.3.1",
35-
"svg-tags": "^1.0.0"
34+
"@vue/shared": "^3.5.13"
3635
},
3736
"devDependencies": {
3837
"@babel/core": "^7.26.9",
3938
"@babel/preset-env": "^7.26.9",
4039
"@types/babel__template": "^7.4.4",
4140
"@types/babel__traverse": "^7.20.6",
42-
"@types/svg-tags": "^1.0.2",
4341
"@vue/test-utils": "^2.4.6",
4442
"regenerator-runtime": "^0.14.1",
4543
"vue": "catalog:"

packages/babel-plugin-jsx/src/utils.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import * as t from '@babel/types';
2-
import htmlTags from 'html-tags';
3-
import svgTags from 'svg-tags';
42
import { type NodePath } from '@babel/traverse';
53
import type { State } from './interface';
64
import SlotFlags from './slotFlags';
7-
5+
import { isHTMLTag , isSVGTag } from '@vue/shared'
86
export const JSX_HELPER_KEY = 'JSX_HELPER_KEY';
97
export const FRAGMENT = 'Fragment';
108
export const KEEP_ALIVE = 'KeepAlive';
@@ -60,8 +58,8 @@ export const checkIsComponent = (
6058
return (
6159
!state.opts.isCustomElement?.(tag) &&
6260
shouldTransformedToSlots(tag) &&
63-
!htmlTags.includes(tag as htmlTags.htmlTags) &&
64-
!svgTags.includes(tag)
61+
!isHTMLTag(tag) &&
62+
!isSVGTag(tag)
6563
);
6664
};
6765

@@ -100,8 +98,8 @@ export const getTag = (
10098
if (namePath.isJSXIdentifier()) {
10199
const { name } = namePath.node;
102100
if (
103-
!htmlTags.includes(name as htmlTags.htmlTags) &&
104-
!svgTags.includes(name)
101+
!isHTMLTag(name) &&
102+
!isSVGTag(name)
105103
) {
106104
return name === FRAGMENT
107105
? createIdentifier(state, FRAGMENT)

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)