Skip to content

Commit a7607de

Browse files
authoredMar 3, 2025··
feat: Support SVG 2 elements, using @vue/shared to ensure consistent behavior with vue (#745)
1 parent fb925b8 commit a7607de

File tree

3 files changed

+8
-26
lines changed

3 files changed

+8
-26
lines changed
 

Diff for: ‎packages/babel-plugin-jsx/package.json

+1-3
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:"

Diff for: ‎packages/babel-plugin-jsx/src/utils.ts

+4-9
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';
3+
import { isHTMLTag, isSVGTag } from '@vue/shared';
54
import type { State } from './interface';
65
import SlotFlags from './slotFlags';
7-
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

@@ -99,10 +97,7 @@ export const getTag = (
9997
const namePath = path.get('openingElement').get('name');
10098
if (namePath.isJSXIdentifier()) {
10199
const { name } = namePath.node;
102-
if (
103-
!htmlTags.includes(name as htmlTags.htmlTags) &&
104-
!svgTags.includes(name)
105-
) {
100+
if (!isHTMLTag(name) && !isSVGTag(name)) {
106101
return name === FRAGMENT
107102
? createIdentifier(state, FRAGMENT)
108103
: path.scope.hasBinding(name)

Diff for: ‎pnpm-lock.yaml

+3-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.