mirror of
https://github.com/vuejs/babel-plugin-jsx.git
synced 2024-11-10 17:49:16 +08:00
fix: should check isCustomElement
(#431)
* fix: respect isCustomElement * chore: yarn lint
This commit is contained in:
parent
77ed541aa3
commit
117b25a56a
@ -46,7 +46,7 @@ const getJSXAttributeValue = (
|
|||||||
|
|
||||||
const buildProps = (path: NodePath<t.JSXElement>, state: State) => {
|
const buildProps = (path: NodePath<t.JSXElement>, state: State) => {
|
||||||
const tag = getTag(path, state);
|
const tag = getTag(path, state);
|
||||||
const isComponent = checkIsComponent(path.get('openingElement'));
|
const isComponent = checkIsComponent(path.get('openingElement'), state);
|
||||||
const props = path.get('openingElement').get('attributes');
|
const props = path.get('openingElement').get('attributes');
|
||||||
const directives: t.ArrayExpression[] = [];
|
const directives: t.ArrayExpression[] = [];
|
||||||
const dynamicPropNames = new Set<string>();
|
const dynamicPropNames = new Set<string>();
|
||||||
|
@ -41,7 +41,7 @@ export const shouldTransformedToSlots = (tag: string) => !(tag.endsWith(FRAGMENT
|
|||||||
* @param path JSXOpeningElement
|
* @param path JSXOpeningElement
|
||||||
* @returns boolean
|
* @returns boolean
|
||||||
*/
|
*/
|
||||||
export const checkIsComponent = (path: NodePath<t.JSXOpeningElement>): boolean => {
|
export const checkIsComponent = (path: NodePath<t.JSXOpeningElement>, state: State): boolean => {
|
||||||
const namePath = path.get('name');
|
const namePath = path.get('name');
|
||||||
|
|
||||||
if (namePath.isJSXMemberExpression()) {
|
if (namePath.isJSXMemberExpression()) {
|
||||||
@ -50,6 +50,10 @@ export const checkIsComponent = (path: NodePath<t.JSXOpeningElement>): boolean =
|
|||||||
|
|
||||||
const tag = (namePath as NodePath<t.JSXIdentifier>).node.name;
|
const tag = (namePath as NodePath<t.JSXIdentifier>).node.name;
|
||||||
|
|
||||||
|
if (state.opts.isCustomElement && state.opts.isCustomElement(tag)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return shouldTransformedToSlots(tag) && !htmlTags.includes(tag) && !svgTags.includes(tag);
|
return shouldTransformedToSlots(tag) && !htmlTags.includes(tag) && !svgTags.includes(tag);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user