mirror of
https://github.com/vuejs/babel-plugin-jsx.git
synced 2025-01-11 00:39:10 +08:00
feat: configurable usePatchFlag
This commit is contained in:
parent
74744fe74b
commit
9b005fcf02
@ -369,14 +369,14 @@ const transformJSXElement = (t, path, state) => {
|
|||||||
const child = children.length === 1 && t.isStringLiteral(children[0])
|
const child = children.length === 1 && t.isStringLiteral(children[0])
|
||||||
? children[0] : t.arrayExpression(children);
|
? children[0] : t.arrayExpression(children);
|
||||||
|
|
||||||
const { compatibleProps } = state.opts;
|
const { compatibleProps, usePatchFlag } = state.opts;
|
||||||
if (compatibleProps && !state.get('compatibleProps')) {
|
if (compatibleProps && !state.get('compatibleProps')) {
|
||||||
state.set('compatibleProps', addDefault(
|
state.set('compatibleProps', addDefault(
|
||||||
path, '@ant-design-vue/babel-helper-vue-compatible-props', { nameHint: '_compatibleProps' },
|
path, '@ant-design-vue/babel-helper-vue-compatible-props', { nameHint: '_compatibleProps' },
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
const createVNode = t.callExpression(createIdentifier(t, state, 'createVNode'), [
|
const createVNode = t.callExpression(createIdentifier(t, state, usePatchFlag ? 'createVNode' : 'h'), [
|
||||||
tag,
|
tag,
|
||||||
compatibleProps ? t.callExpression(state.get('compatibleProps'), [props]) : props,
|
compatibleProps ? t.callExpression(state.get('compatibleProps'), [props]) : props,
|
||||||
children[0]
|
children[0]
|
||||||
@ -400,8 +400,8 @@ const transformJSXElement = (t, path, state) => {
|
|||||||
])
|
])
|
||||||
: child
|
: child
|
||||||
) : t.nullLiteral(),
|
) : t.nullLiteral(),
|
||||||
patchFlag && t.addComment(t.numericLiteral(patchFlag), 'trailing', ` ${flagNames} `, false),
|
patchFlag && usePatchFlag && t.addComment(t.numericLiteral(patchFlag), 'trailing', ` ${flagNames} `, false),
|
||||||
dynamicPropNames.size
|
dynamicPropNames.size && usePatchFlag
|
||||||
&& t.arrayExpression([...dynamicPropNames.keys()].map((name) => t.stringLiteral(name))),
|
&& t.arrayExpression([...dynamicPropNames.keys()].map((name) => t.stringLiteral(name))),
|
||||||
].filter(Boolean));
|
].filter(Boolean));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user