Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support SVG 2 elements, using @vue/shared to ensure consistent behavi… #745

Merged
merged 3 commits into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions packages/babel-plugin-jsx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,13 @@
"@babel/types": "^7.26.9",
"@vue/babel-helper-vue-transform-on": "workspace:*",
"@vue/babel-plugin-resolve-type": "workspace:*",
"html-tags": "^3.3.1",
"svg-tags": "^1.0.0"
"@vue/shared": "^3.5.13"
},
"devDependencies": {
"@babel/core": "^7.26.9",
"@babel/preset-env": "^7.26.9",
"@types/babel__template": "^7.4.4",
"@types/babel__traverse": "^7.20.6",
"@types/svg-tags": "^1.0.2",
"@vue/test-utils": "^2.4.6",
"regenerator-runtime": "^0.14.1",
"vue": "catalog:"
Expand Down
13 changes: 4 additions & 9 deletions packages/babel-plugin-jsx/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import * as t from '@babel/types';
import htmlTags from 'html-tags';
import svgTags from 'svg-tags';
import { type NodePath } from '@babel/traverse';
import { isHTMLTag, isSVGTag } from '@vue/shared';
import type { State } from './interface';
import SlotFlags from './slotFlags';

export const JSX_HELPER_KEY = 'JSX_HELPER_KEY';
export const FRAGMENT = 'Fragment';
export const KEEP_ALIVE = 'KeepAlive';
Expand Down Expand Up @@ -60,8 +58,8 @@ export const checkIsComponent = (
return (
!state.opts.isCustomElement?.(tag) &&
shouldTransformedToSlots(tag) &&
!htmlTags.includes(tag as htmlTags.htmlTags) &&
!svgTags.includes(tag)
!isHTMLTag(tag) &&
!isSVGTag(tag)
);
};

Expand Down Expand Up @@ -99,10 +97,7 @@ export const getTag = (
const namePath = path.get('openingElement').get('name');
if (namePath.isJSXIdentifier()) {
const { name } = namePath.node;
if (
!htmlTags.includes(name as htmlTags.htmlTags) &&
!svgTags.includes(name)
) {
if (!isHTMLTag(name) && !isSVGTag(name)) {
return name === FRAGMENT
? createIdentifier(state, FRAGMENT)
: path.scope.hasBinding(name)
Expand Down
17 changes: 3 additions & 14 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading