mirror of
https://github.com/vuejs/babel-plugin-jsx.git
synced 2024-11-10 17:49:16 +08:00
test: isCustomElement snap
This commit is contained in:
parent
117b25a56a
commit
3dcca6d06d
@ -50,11 +50,7 @@ export const checkIsComponent = (path: NodePath<t.JSXOpeningElement>, state: Sta
|
|||||||
|
|
||||||
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 !state.opts.isCustomElement?.(tag) && shouldTransformedToSlots(tag) && !htmlTags.includes(tag) && !svgTags.includes(tag);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return shouldTransformedToSlots(tag) && !htmlTags.includes(tag) && !svgTags.includes(tag);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -115,6 +115,12 @@ _withDirectives(_createVNode(\\"input\\", {
|
|||||||
}, null, 8, [\\"onUpdate:modelValue\\"]), [[_vModelText, test]]);"
|
}, null, 8, [\\"onUpdate:modelValue\\"]), [[_vModelText, test]]);"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`isCustomElement: isCustomElement 1`] = `
|
||||||
|
"import { createVNode as _createVNode, createTextVNode as _createTextVNode } from \\"vue\\";
|
||||||
|
|
||||||
|
_createVNode(\\"foo\\", null, [_createVNode(\\"span\\", null, [_createTextVNode(\\"foo\\")])]);"
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`named import specifier \`Keep Alive\`: named import specifier \`Keep Alive\` 1`] = `
|
exports[`named import specifier \`Keep Alive\`: named import specifier \`Keep Alive\` 1`] = `
|
||||||
"import { createVNode as _createVNode, createTextVNode as _createTextVNode } from \\"vue\\";
|
"import { createVNode as _createVNode, createTextVNode as _createTextVNode } from \\"vue\\";
|
||||||
import { KeepAlive } from 'vue';
|
import { KeepAlive } from 'vue';
|
||||||
|
@ -304,3 +304,17 @@ pragmaTests.forEach(({
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const isCustomElementTests = [{
|
||||||
|
name: 'isCustomElement',
|
||||||
|
from: '<foo><span>foo</span></foo>'
|
||||||
|
}]
|
||||||
|
|
||||||
|
isCustomElementTests.forEach(({name, from }) => {
|
||||||
|
test(
|
||||||
|
name,
|
||||||
|
async () => {
|
||||||
|
expect(await transpile(from, { isCustomElement: tag => tag === 'foo' })).toMatchSnapshot(name);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user