@vue/compiler-dom 3.6.0-alpha.2 → 3.6.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-dom v3.6.0-alpha.2
2
+ * @vue/compiler-dom v3.6.0-alpha.3
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -411,46 +411,46 @@ const transformTransition = (node, context) => {
411
411
  if (node.type === 1 && node.tagType === 1) {
412
412
  const component = context.isBuiltInComponent(node.tag);
413
413
  if (component === TRANSITION) {
414
- return () => {
415
- if (!node.children.length) {
416
- return;
417
- }
418
- if (hasMultipleChildren(node)) {
419
- context.onError(
420
- createDOMCompilerError(
421
- 62,
422
- {
423
- start: node.children[0].loc.start,
424
- end: node.children[node.children.length - 1].loc.end,
425
- source: ""
426
- }
427
- )
428
- );
429
- }
430
- const child = node.children[0];
431
- if (child.type === 1) {
432
- for (const p of child.props) {
433
- if (p.type === 7 && p.name === "show") {
434
- node.props.push({
435
- type: 6,
436
- name: "persisted",
437
- nameLoc: node.loc,
438
- value: void 0,
439
- loc: node.loc
440
- });
441
- }
442
- }
443
- }
444
- };
414
+ return postTransformTransition(node, context.onError);
445
415
  }
446
416
  }
447
417
  };
448
- function hasMultipleChildren(node) {
418
+ function postTransformTransition(node, onError, hasMultipleChildren = defaultHasMultipleChildren) {
419
+ return () => {
420
+ if (!node.children.length) {
421
+ return;
422
+ }
423
+ if (hasMultipleChildren(node)) {
424
+ onError(
425
+ createDOMCompilerError(62, {
426
+ start: node.children[0].loc.start,
427
+ end: node.children[node.children.length - 1].loc.end,
428
+ source: ""
429
+ })
430
+ );
431
+ }
432
+ const child = node.children[0];
433
+ if (child.type === 1) {
434
+ for (const p of child.props) {
435
+ if (p.type === 7 && p.name === "show") {
436
+ node.props.push({
437
+ type: 6,
438
+ name: "persisted",
439
+ nameLoc: node.loc,
440
+ value: void 0,
441
+ loc: node.loc
442
+ });
443
+ }
444
+ }
445
+ }
446
+ };
447
+ }
448
+ function defaultHasMultipleChildren(node) {
449
449
  const children = node.children = node.children.filter(
450
450
  (c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
451
451
  );
452
452
  const child = children[0];
453
- return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(hasMultipleChildren);
453
+ return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(defaultHasMultipleChildren);
454
454
  }
455
455
 
456
456
  const expReplaceRE = /__VUE_EXP_START__(.*?)__VUE_EXP_END__/g;
@@ -525,7 +525,7 @@ const getCachedNode = (node) => {
525
525
  return node.codegenNode;
526
526
  }
527
527
  };
528
- const dataAriaRE = /^(data|aria)-/;
528
+ const dataAriaRE = /^(?:data|aria)-/;
529
529
  const isStringifiableAttr = (name, ns) => {
530
530
  return (ns === 0 ? shared.isKnownHtmlAttr(name) : ns === 1 ? shared.isKnownSvgAttr(name) : ns === 2 ? shared.isKnownMathMLAttr(name) : false) || dataAriaRE.test(name);
531
531
  };
@@ -536,6 +536,9 @@ function analyzeNode(node) {
536
536
  if (node.type === 1 && isNonStringifiable(node.tag)) {
537
537
  return false;
538
538
  }
539
+ if (node.type === 1 && compilerCore.findDir(node, "once", true)) {
540
+ return false;
541
+ }
539
542
  if (node.type === 12) {
540
543
  return [1, 0];
541
544
  }
@@ -929,6 +932,7 @@ exports.createDOMCompilerError = createDOMCompilerError;
929
932
  exports.isValidHTMLNesting = isValidHTMLNesting;
930
933
  exports.parse = parse;
931
934
  exports.parserOptions = parserOptions;
935
+ exports.postTransformTransition = postTransformTransition;
932
936
  exports.resolveModifiers = resolveModifiers;
933
937
  exports.transformStyle = transformStyle;
934
938
  Object.keys(compilerCore).forEach(function (k) {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-dom v3.6.0-alpha.2
2
+ * @vue/compiler-dom v3.6.0-alpha.3
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -389,6 +389,44 @@ const transformShow = (dir, node, context) => {
389
389
  };
390
390
  };
391
391
 
392
+ function postTransformTransition(node, onError, hasMultipleChildren = defaultHasMultipleChildren) {
393
+ return () => {
394
+ if (!node.children.length) {
395
+ return;
396
+ }
397
+ if (hasMultipleChildren(node)) {
398
+ onError(
399
+ createDOMCompilerError(62, {
400
+ start: node.children[0].loc.start,
401
+ end: node.children[node.children.length - 1].loc.end,
402
+ source: ""
403
+ })
404
+ );
405
+ }
406
+ const child = node.children[0];
407
+ if (child.type === 1) {
408
+ for (const p of child.props) {
409
+ if (p.type === 7 && p.name === "show") {
410
+ node.props.push({
411
+ type: 6,
412
+ name: "persisted",
413
+ nameLoc: node.loc,
414
+ value: void 0,
415
+ loc: node.loc
416
+ });
417
+ }
418
+ }
419
+ }
420
+ };
421
+ }
422
+ function defaultHasMultipleChildren(node) {
423
+ const children = node.children = node.children.filter(
424
+ (c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
425
+ );
426
+ const child = children[0];
427
+ return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(defaultHasMultipleChildren);
428
+ }
429
+
392
430
  const expReplaceRE = /__VUE_EXP_START__(.*?)__VUE_EXP_END__/g;
393
431
  const stringifyStatic = (children, context, parent) => {
394
432
  if (context.scopes.vSlot > 0) {
@@ -461,7 +499,7 @@ const getCachedNode = (node) => {
461
499
  return node.codegenNode;
462
500
  }
463
501
  };
464
- const dataAriaRE = /^(data|aria)-/;
502
+ const dataAriaRE = /^(?:data|aria)-/;
465
503
  const isStringifiableAttr = (name, ns) => {
466
504
  return (ns === 0 ? shared.isKnownHtmlAttr(name) : ns === 1 ? shared.isKnownSvgAttr(name) : ns === 2 ? shared.isKnownMathMLAttr(name) : false) || dataAriaRE.test(name);
467
505
  };
@@ -472,6 +510,9 @@ function analyzeNode(node) {
472
510
  if (node.type === 1 && isNonStringifiable(node.tag)) {
473
511
  return false;
474
512
  }
513
+ if (node.type === 1 && compilerCore.findDir(node, "once", true)) {
514
+ return false;
515
+ }
475
516
  if (node.type === 12) {
476
517
  return [1, 0];
477
518
  }
@@ -849,6 +890,7 @@ exports.createDOMCompilerError = createDOMCompilerError;
849
890
  exports.isValidHTMLNesting = isValidHTMLNesting;
850
891
  exports.parse = parse;
851
892
  exports.parserOptions = parserOptions;
893
+ exports.postTransformTransition = postTransformTransition;
852
894
  exports.resolveModifiers = resolveModifiers;
853
895
  exports.transformStyle = transformStyle;
854
896
  Object.keys(compilerCore).forEach(function (k) {
@@ -1,4 +1,4 @@
1
- import { ParserOptions, NodeTransform, SourceLocation, CompilerError, ExpressionNode, SimpleExpressionNode, TransformContext, DirectiveTransform, RootNode, CompilerOptions, CodegenResult } from '@vue/compiler-core';
1
+ import { ParserOptions, NodeTransform, SourceLocation, CompilerError, ExpressionNode, SimpleExpressionNode, TransformContext, ComponentNode, DirectiveTransform, RootNode, CompilerOptions, CodegenResult } from '@vue/compiler-core';
2
2
  export * from '@vue/compiler-core';
3
3
 
4
4
  export declare const parserOptions: ParserOptions;
@@ -55,6 +55,8 @@ export declare const resolveModifiers: (key: ExpressionNode | string, modifiers:
55
55
  */
56
56
  export declare function isValidHTMLNesting(parent: string, child: string): boolean;
57
57
 
58
+ export declare function postTransformTransition(node: ComponentNode, onError: (error: CompilerError) => void, hasMultipleChildren?: (node: ComponentNode) => boolean): () => void;
59
+
58
60
  export declare const DOMNodeTransforms: NodeTransform[];
59
61
  export declare const DOMDirectiveTransforms: Record<string, DirectiveTransform>;
60
62
  export declare function compile(src: string | RootNode, options?: CompilerOptions): CodegenResult;
@@ -1,9 +1,8 @@
1
1
  /**
2
- * @vue/compiler-dom v3.6.0-alpha.2
2
+ * @vue/compiler-dom v3.6.0-alpha.3
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
6
- /*! #__NO_SIDE_EFFECTS__ */
7
6
  // @__NO_SIDE_EFFECTS__
8
7
  function makeMap(str) {
9
8
  const map = /* @__PURE__ */ Object.create(null);
@@ -31,10 +30,10 @@ const isBuiltInDirective = /* @__PURE__ */ makeMap(
31
30
  );
32
31
  const cacheStringFunction = (fn) => {
33
32
  const cache = /* @__PURE__ */ Object.create(null);
34
- return (str) => {
33
+ return ((str) => {
35
34
  const hit = cache[str];
36
35
  return hit || (cache[str] = fn(str));
37
- };
36
+ });
38
37
  };
39
38
  const camelizeRE = /-(\w)/g;
40
39
  const camelizeReplacer = (_, c) => c ? c.toUpperCase() : "";
@@ -1647,7 +1646,8 @@ function walkFunctionParams(node, onIdent) {
1647
1646
  }
1648
1647
  }
1649
1648
  function walkBlockDeclarations(block, onIdent) {
1650
- for (const stmt of block.body) {
1649
+ const body = block.type === "SwitchCase" ? block.consequent : block.body;
1650
+ for (const stmt of body) {
1651
1651
  if (stmt.type === "VariableDeclaration") {
1652
1652
  if (stmt.declare) continue;
1653
1653
  for (const decl of stmt.declarations) {
@@ -1660,6 +1660,8 @@ function walkBlockDeclarations(block, onIdent) {
1660
1660
  onIdent(stmt.id);
1661
1661
  } else if (isForStatement(stmt)) {
1662
1662
  walkForStatement(stmt, true, onIdent);
1663
+ } else if (stmt.type === "SwitchStatement") {
1664
+ walkSwitchStatement(stmt, true, onIdent);
1663
1665
  }
1664
1666
  }
1665
1667
  }
@@ -1676,6 +1678,20 @@ function walkForStatement(stmt, isVar, onIdent) {
1676
1678
  }
1677
1679
  }
1678
1680
  }
1681
+ function walkSwitchStatement(stmt, isVar, onIdent) {
1682
+ for (const cs of stmt.cases) {
1683
+ for (const stmt2 of cs.consequent) {
1684
+ if (stmt2.type === "VariableDeclaration" && (stmt2.kind === "var" ? isVar : !isVar)) {
1685
+ for (const decl of stmt2.declarations) {
1686
+ for (const id of extractIdentifiers(decl.id)) {
1687
+ onIdent(id);
1688
+ }
1689
+ }
1690
+ }
1691
+ }
1692
+ walkBlockDeclarations(cs, onIdent);
1693
+ }
1694
+ }
1679
1695
  function extractIdentifiers(param, nodes = []) {
1680
1696
  switch (param.type) {
1681
1697
  case "Identifier":
@@ -1806,7 +1822,7 @@ function isCoreComponent(tag) {
1806
1822
  return BASE_TRANSITION;
1807
1823
  }
1808
1824
  }
1809
- const nonIdentifierRE = /^\d|[^\$\w\xA0-\uFFFF]/;
1825
+ const nonIdentifierRE = /^$|^\d|[^\$\w\xA0-\uFFFF]/;
1810
1826
  const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
1811
1827
  const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
1812
1828
  const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
@@ -1876,7 +1892,7 @@ const isMemberExpressionBrowser = (exp) => {
1876
1892
  };
1877
1893
  const isMemberExpressionNode = NOOP ;
1878
1894
  const isMemberExpression = isMemberExpressionBrowser ;
1879
- const fnExpRE = /^\s*(async\s*)?(\([^)]*?\)|[\w$_]+)\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
1895
+ const fnExpRE = /^\s*(?:async\s*)?(?:\([^)]*?\)|[\w$_]+)\s*(?::[^=]+)?=>|^\s*(?:async\s+)?function(?:\s+[\w$]+)?\s*\(/;
1880
1896
  const isFnExpressionBrowser = (exp) => fnExpRE.test(getExpSource(exp));
1881
1897
  const isFnExpressionNode = NOOP ;
1882
1898
  const isFnExpression = isFnExpressionBrowser ;
@@ -1945,6 +1961,9 @@ function hasDynamicKeyVBind(node) {
1945
1961
  function isText$1(node) {
1946
1962
  return node.type === 5 || node.type === 2;
1947
1963
  }
1964
+ function isVPre(p) {
1965
+ return p.type === 7 && p.name === "pre";
1966
+ }
1948
1967
  function isVSlot(p) {
1949
1968
  return p.type === 7 && p.name === "slot";
1950
1969
  }
@@ -2243,7 +2262,7 @@ const tokenizer = new Tokenizer(stack, {
2243
2262
  ondirarg(start, end) {
2244
2263
  if (start === end) return;
2245
2264
  const arg = getSlice(start, end);
2246
- if (inVPre) {
2265
+ if (inVPre && !isVPre(currentProp)) {
2247
2266
  currentProp.name += arg;
2248
2267
  setLocEnd(currentProp.nameLoc, end);
2249
2268
  } else {
@@ -2258,7 +2277,7 @@ const tokenizer = new Tokenizer(stack, {
2258
2277
  },
2259
2278
  ondirmodifier(start, end) {
2260
2279
  const mod = getSlice(start, end);
2261
- if (inVPre) {
2280
+ if (inVPre && !isVPre(currentProp)) {
2262
2281
  currentProp.name += "." + mod;
2263
2282
  setLocEnd(currentProp.nameLoc, end);
2264
2283
  } else if (currentProp.name === "slot") {
@@ -2886,6 +2905,11 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
2886
2905
  } else if (child.type === 12) {
2887
2906
  const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
2888
2907
  if (constantType >= 2) {
2908
+ if (child.codegenNode.type === 14 && child.codegenNode.arguments.length > 0) {
2909
+ child.codegenNode.arguments.push(
2910
+ -1 + (` /* ${PatchFlagNames[-1]} */` )
2911
+ );
2912
+ }
2889
2913
  toCache.push(child);
2890
2914
  continue;
2891
2915
  }
@@ -2914,7 +2938,6 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
2914
2938
  }
2915
2939
  }
2916
2940
  let cachedAsArray = false;
2917
- const slotCacheKeys = [];
2918
2941
  if (toCache.length === children.length && node.type === 1) {
2919
2942
  if (node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && isArray(node.codegenNode.children)) {
2920
2943
  node.codegenNode.children = getCacheExpression(
@@ -2924,7 +2947,6 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
2924
2947
  } else if (node.tagType === 1 && node.codegenNode && node.codegenNode.type === 13 && node.codegenNode.children && !isArray(node.codegenNode.children) && node.codegenNode.children.type === 15) {
2925
2948
  const slot = getSlotNode(node.codegenNode, "default");
2926
2949
  if (slot) {
2927
- slotCacheKeys.push(context.cached.length);
2928
2950
  slot.returns = getCacheExpression(
2929
2951
  createArrayExpression(slot.returns)
2930
2952
  );
@@ -2934,7 +2956,6 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
2934
2956
  const slotName = findDir(node, "slot", true);
2935
2957
  const slot = slotName && slotName.arg && getSlotNode(parent.codegenNode, slotName.arg);
2936
2958
  if (slot) {
2937
- slotCacheKeys.push(context.cached.length);
2938
2959
  slot.returns = getCacheExpression(
2939
2960
  createArrayExpression(slot.returns)
2940
2961
  );
@@ -2944,23 +2965,12 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
2944
2965
  }
2945
2966
  if (!cachedAsArray) {
2946
2967
  for (const child of toCache) {
2947
- slotCacheKeys.push(context.cached.length);
2948
2968
  child.codegenNode = context.cache(child.codegenNode);
2949
2969
  }
2950
2970
  }
2951
- if (slotCacheKeys.length && node.type === 1 && node.tagType === 1 && node.codegenNode && node.codegenNode.type === 13 && node.codegenNode.children && !isArray(node.codegenNode.children) && node.codegenNode.children.type === 15) {
2952
- node.codegenNode.children.properties.push(
2953
- createObjectProperty(
2954
- `__`,
2955
- createSimpleExpression(JSON.stringify(slotCacheKeys), false)
2956
- )
2957
- );
2958
- }
2959
2971
  function getCacheExpression(value) {
2960
2972
  const exp = context.cache(value);
2961
- if (inFor && context.hmr) {
2962
- exp.needArraySpread = true;
2963
- }
2973
+ exp.needArraySpread = true;
2964
2974
  return exp;
2965
2975
  }
2966
2976
  function getSlotNode(node2, name) {
@@ -4111,7 +4121,7 @@ function stringifyExpression(exp) {
4111
4121
  }
4112
4122
 
4113
4123
  const transformIf = createStructuralDirectiveTransform(
4114
- /^(if|else|else-if)$/,
4124
+ /^(?:if|else|else-if)$/,
4115
4125
  (node, dir, context) => {
4116
4126
  return processIf(node, dir, context, (ifNode, branch, isRoot) => {
4117
4127
  const siblings = context.parent.children;
@@ -4180,7 +4190,7 @@ function processIf(node, dir, context, processCodegen) {
4180
4190
  continue;
4181
4191
  }
4182
4192
  if (sibling && sibling.type === 9) {
4183
- if (dir.name === "else-if" && sibling.branches[sibling.branches.length - 1].condition === void 0) {
4193
+ if ((dir.name === "else-if" || dir.name === "else") && sibling.branches[sibling.branches.length - 1].condition === void 0) {
4184
4194
  context.onError(
4185
4195
  createCompilerError(30, node.loc)
4186
4196
  );
@@ -4329,80 +4339,6 @@ function getParentCondition(node) {
4329
4339
  }
4330
4340
  }
4331
4341
 
4332
- const transformBind = (dir, _node, context) => {
4333
- const { modifiers, loc } = dir;
4334
- const arg = dir.arg;
4335
- let { exp } = dir;
4336
- if (exp && exp.type === 4 && !exp.content.trim()) {
4337
- {
4338
- exp = void 0;
4339
- }
4340
- }
4341
- if (!exp) {
4342
- if (arg.type !== 4 || !arg.isStatic) {
4343
- context.onError(
4344
- createCompilerError(
4345
- 52,
4346
- arg.loc
4347
- )
4348
- );
4349
- return {
4350
- props: [
4351
- createObjectProperty(arg, createSimpleExpression("", true, loc))
4352
- ]
4353
- };
4354
- }
4355
- transformBindShorthand(dir);
4356
- exp = dir.exp;
4357
- }
4358
- if (arg.type !== 4) {
4359
- arg.children.unshift(`(`);
4360
- arg.children.push(`) || ""`);
4361
- } else if (!arg.isStatic) {
4362
- arg.content = `${arg.content} || ""`;
4363
- }
4364
- if (modifiers.some((mod) => mod.content === "camel")) {
4365
- if (arg.type === 4) {
4366
- if (arg.isStatic) {
4367
- arg.content = camelize(arg.content);
4368
- } else {
4369
- arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
4370
- }
4371
- } else {
4372
- arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
4373
- arg.children.push(`)`);
4374
- }
4375
- }
4376
- if (!context.inSSR) {
4377
- if (modifiers.some((mod) => mod.content === "prop")) {
4378
- injectPrefix(arg, ".");
4379
- }
4380
- if (modifiers.some((mod) => mod.content === "attr")) {
4381
- injectPrefix(arg, "^");
4382
- }
4383
- }
4384
- return {
4385
- props: [createObjectProperty(arg, exp)]
4386
- };
4387
- };
4388
- const transformBindShorthand = (dir, context) => {
4389
- const arg = dir.arg;
4390
- const propName = camelize(arg.content);
4391
- dir.exp = createSimpleExpression(propName, false, arg.loc);
4392
- };
4393
- const injectPrefix = (arg, prefix) => {
4394
- if (arg.type === 4) {
4395
- if (arg.isStatic) {
4396
- arg.content = prefix + arg.content;
4397
- } else {
4398
- arg.content = `\`${prefix}\${${arg.content}}\``;
4399
- }
4400
- } else {
4401
- arg.children.unshift(`'${prefix}' + (`);
4402
- arg.children.push(`)`);
4403
- }
4404
- };
4405
-
4406
4342
  const transformFor = createStructuralDirectiveTransform(
4407
4343
  "for",
4408
4344
  (node, dir, context) => {
@@ -4414,10 +4350,7 @@ const transformFor = createStructuralDirectiveTransform(
4414
4350
  const isTemplate = isTemplateNode(node);
4415
4351
  const memo = findDir(node, "memo");
4416
4352
  const keyProp = findProp(node, `key`, false, true);
4417
- const isDirKey = keyProp && keyProp.type === 7;
4418
- if (isDirKey && !keyProp.exp) {
4419
- transformBindShorthand(keyProp);
4420
- }
4353
+ keyProp && keyProp.type === 7;
4421
4354
  let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
4422
4355
  const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
4423
4356
  const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
@@ -4717,7 +4650,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
4717
4650
  );
4718
4651
  } else if (vElse = findDir(
4719
4652
  slotElement,
4720
- /^else(-if)?$/,
4653
+ /^else(?:-if)?$/,
4721
4654
  true
4722
4655
  /* allowEmpty */
4723
4656
  )) {
@@ -4729,7 +4662,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
4729
4662
  break;
4730
4663
  }
4731
4664
  }
4732
- if (prev && isTemplateNode(prev) && findDir(prev, /^(else-)?if$/)) {
4665
+ if (prev && isTemplateNode(prev) && findDir(prev, /^(?:else-)?if$/)) {
4733
4666
  let conditional = dynamicSlots[dynamicSlots.length - 1];
4734
4667
  while (conditional.alternate.type === 19) {
4735
4668
  conditional = conditional.alternate;
@@ -5589,6 +5522,58 @@ const transformOn$1 = (dir, node, context, augmentor) => {
5589
5522
  return ret;
5590
5523
  };
5591
5524
 
5525
+ const transformBind = (dir, _node, context) => {
5526
+ const { modifiers, loc } = dir;
5527
+ const arg = dir.arg;
5528
+ let { exp } = dir;
5529
+ if (exp && exp.type === 4 && !exp.content.trim()) {
5530
+ {
5531
+ exp = void 0;
5532
+ }
5533
+ }
5534
+ if (arg.type !== 4) {
5535
+ arg.children.unshift(`(`);
5536
+ arg.children.push(`) || ""`);
5537
+ } else if (!arg.isStatic) {
5538
+ arg.content = arg.content ? `${arg.content} || ""` : `""`;
5539
+ }
5540
+ if (modifiers.some((mod) => mod.content === "camel")) {
5541
+ if (arg.type === 4) {
5542
+ if (arg.isStatic) {
5543
+ arg.content = camelize(arg.content);
5544
+ } else {
5545
+ arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
5546
+ }
5547
+ } else {
5548
+ arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
5549
+ arg.children.push(`)`);
5550
+ }
5551
+ }
5552
+ if (!context.inSSR) {
5553
+ if (modifiers.some((mod) => mod.content === "prop")) {
5554
+ injectPrefix(arg, ".");
5555
+ }
5556
+ if (modifiers.some((mod) => mod.content === "attr")) {
5557
+ injectPrefix(arg, "^");
5558
+ }
5559
+ }
5560
+ return {
5561
+ props: [createObjectProperty(arg, exp)]
5562
+ };
5563
+ };
5564
+ const injectPrefix = (arg, prefix) => {
5565
+ if (arg.type === 4) {
5566
+ if (arg.isStatic) {
5567
+ arg.content = prefix + arg.content;
5568
+ } else {
5569
+ arg.content = `\`${prefix}\${${arg.content}}\``;
5570
+ }
5571
+ } else {
5572
+ arg.children.unshift(`'${prefix}' + (`);
5573
+ arg.children.push(`)`);
5574
+ }
5575
+ };
5576
+
5592
5577
  const transformText = (node, context) => {
5593
5578
  if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
5594
5579
  return () => {
@@ -5897,7 +5882,7 @@ const seen = /* @__PURE__ */ new WeakSet();
5897
5882
  const transformMemo = (node, context) => {
5898
5883
  if (node.type === 1) {
5899
5884
  const dir = findDir(node, "memo");
5900
- if (!dir || seen.has(node)) {
5885
+ if (!dir || seen.has(node) || context.inSSR) {
5901
5886
  return;
5902
5887
  }
5903
5888
  seen.add(node);
@@ -5919,9 +5904,36 @@ const transformMemo = (node, context) => {
5919
5904
  }
5920
5905
  };
5921
5906
 
5907
+ const transformVBindShorthand = (node, context) => {
5908
+ if (node.type === 1) {
5909
+ for (const prop of node.props) {
5910
+ if (prop.type === 7 && prop.name === "bind" && (!prop.exp || // #13930 :foo in in-DOM templates will be parsed into :foo="" by browser
5911
+ prop.exp.type === 4 && !prop.exp.content.trim()) && prop.arg) {
5912
+ const arg = prop.arg;
5913
+ if (arg.type !== 4 || !arg.isStatic) {
5914
+ context.onError(
5915
+ createCompilerError(
5916
+ 52,
5917
+ arg.loc
5918
+ )
5919
+ );
5920
+ prop.exp = createSimpleExpression("", true, arg.loc);
5921
+ } else {
5922
+ const propName = camelize(arg.content);
5923
+ if (validFirstIdentCharRE.test(propName[0]) || // allow hyphen first char for https://github.com/vuejs/language-tools/pull/3424
5924
+ propName[0] === "-") {
5925
+ prop.exp = createSimpleExpression(propName, false, arg.loc);
5926
+ }
5927
+ }
5928
+ }
5929
+ }
5930
+ }
5931
+ };
5932
+
5922
5933
  function getBaseTransformPreset(prefixIdentifiers) {
5923
5934
  return [
5924
5935
  [
5936
+ transformVBindShorthand,
5925
5937
  transformOnce,
5926
5938
  transformIf,
5927
5939
  transformMemo,
@@ -6411,46 +6423,46 @@ const transformTransition = (node, context) => {
6411
6423
  if (node.type === 1 && node.tagType === 1) {
6412
6424
  const component = context.isBuiltInComponent(node.tag);
6413
6425
  if (component === TRANSITION) {
6414
- return () => {
6415
- if (!node.children.length) {
6416
- return;
6417
- }
6418
- if (hasMultipleChildren(node)) {
6419
- context.onError(
6420
- createDOMCompilerError(
6421
- 62,
6422
- {
6423
- start: node.children[0].loc.start,
6424
- end: node.children[node.children.length - 1].loc.end,
6425
- source: ""
6426
- }
6427
- )
6428
- );
6429
- }
6430
- const child = node.children[0];
6431
- if (child.type === 1) {
6432
- for (const p of child.props) {
6433
- if (p.type === 7 && p.name === "show") {
6434
- node.props.push({
6435
- type: 6,
6436
- name: "persisted",
6437
- nameLoc: node.loc,
6438
- value: void 0,
6439
- loc: node.loc
6440
- });
6441
- }
6442
- }
6443
- }
6444
- };
6426
+ return postTransformTransition(node, context.onError);
6445
6427
  }
6446
6428
  }
6447
6429
  };
6448
- function hasMultipleChildren(node) {
6430
+ function postTransformTransition(node, onError, hasMultipleChildren = defaultHasMultipleChildren) {
6431
+ return () => {
6432
+ if (!node.children.length) {
6433
+ return;
6434
+ }
6435
+ if (hasMultipleChildren(node)) {
6436
+ onError(
6437
+ createDOMCompilerError(62, {
6438
+ start: node.children[0].loc.start,
6439
+ end: node.children[node.children.length - 1].loc.end,
6440
+ source: ""
6441
+ })
6442
+ );
6443
+ }
6444
+ const child = node.children[0];
6445
+ if (child.type === 1) {
6446
+ for (const p of child.props) {
6447
+ if (p.type === 7 && p.name === "show") {
6448
+ node.props.push({
6449
+ type: 6,
6450
+ name: "persisted",
6451
+ nameLoc: node.loc,
6452
+ value: void 0,
6453
+ loc: node.loc
6454
+ });
6455
+ }
6456
+ }
6457
+ }
6458
+ };
6459
+ }
6460
+ function defaultHasMultipleChildren(node) {
6449
6461
  const children = node.children = node.children.filter(
6450
6462
  (c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
6451
6463
  );
6452
6464
  const child = children[0];
6453
- return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(hasMultipleChildren);
6465
+ return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(defaultHasMultipleChildren);
6454
6466
  }
6455
6467
 
6456
6468
  const ignoreSideEffectTags = (node, context) => {
@@ -6679,4 +6691,4 @@ function parse(template, options = {}) {
6679
6691
  return baseParse(template, extend({}, parserOptions, options));
6680
6692
  }
6681
6693
 
6682
- export { BASE_TRANSITION, BindingTypes, CAMELIZE, CAPITALIZE, CREATE_BLOCK, CREATE_COMMENT, CREATE_ELEMENT_BLOCK, CREATE_ELEMENT_VNODE, CREATE_SLOTS, CREATE_STATIC, CREATE_TEXT, CREATE_VNODE, CompilerDeprecationTypes, ConstantTypes, DOMDirectiveTransforms, DOMErrorCodes, DOMErrorMessages, DOMNodeTransforms, ElementTypes, ErrorCodes, FRAGMENT, GUARD_REACTIVE_PROPS, IS_MEMO_SAME, IS_REF, KEEP_ALIVE, MERGE_PROPS, NORMALIZE_CLASS, NORMALIZE_PROPS, NORMALIZE_STYLE, Namespaces, NewlineType, NodeTypes, OPEN_BLOCK, POP_SCOPE_ID, PUSH_SCOPE_ID, RENDER_LIST, RENDER_SLOT, RESOLVE_COMPONENT, RESOLVE_DIRECTIVE, RESOLVE_DYNAMIC_COMPONENT, RESOLVE_FILTER, SET_BLOCK_TRACKING, SUSPENSE, TELEPORT, TO_DISPLAY_STRING, TO_HANDLERS, TO_HANDLER_KEY, TRANSITION, TRANSITION_GROUP, TS_NODE_TYPES, UNREF, V_MODEL_CHECKBOX, V_MODEL_DYNAMIC, V_MODEL_RADIO, V_MODEL_SELECT, V_MODEL_TEXT, V_ON_WITH_KEYS, V_ON_WITH_MODIFIERS, V_SHOW, WITH_CTX, WITH_DIRECTIVES, WITH_MEMO, advancePositionWithClone, advancePositionWithMutation, assert, baseCompile, baseParse, buildDirectiveArgs, buildProps, buildSlots, checkCompatEnabled, compile, convertToBlock, createArrayExpression, createAssignmentExpression, createBlockStatement, createCacheExpression, createCallExpression, createCompilerError, createCompoundExpression, createConditionalExpression, createDOMCompilerError, createForLoopParams, createFunctionExpression, createIfStatement, createInterpolation, createObjectExpression, createObjectProperty, createReturnStatement, createRoot, createSequenceExpression, createSimpleExpression, createStructuralDirectiveTransform, createTemplateLiteral, createTransformContext, createVNodeCall, defaultOnError, defaultOnWarn, errorMessages, extractIdentifiers, findDir, findProp, forAliasRE, generate, generateCodeFrame, getBaseTransformPreset, getConstantType, getMemoedVNodeCall, getSelfName, getVNodeBlockHelper, getVNodeHelper, hasDynamicKeyVBind, hasScopeRef, helperNameMap, injectProp, isConstantNode, isCoreComponent, isFnExpression, isFnExpressionBrowser, isFnExpressionNode, isFunctionType, isInDestructureAssignment, isInNewExpression, isLiteralWhitelisted, isMemberExpression, isMemberExpressionBrowser, isMemberExpressionNode, isReferencedIdentifier, isSimpleIdentifier, isSlotOutlet, isStaticArgOf, isStaticExp, isStaticNode, isStaticProperty, isStaticPropertyKey, isTemplateNode, isText$1 as isText, isVSlot, isValidHTMLNesting, locStub, noopDirectiveTransform, parse, parserOptions, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, resolveModifiers, stringifyExpression, toValidAssetId, trackSlotScopes, trackVForSlotScopes, transform, transformBind, transformElement, transformExpression, transformModel$1 as transformModel, transformOn$1 as transformOn, transformStyle, traverseNode, unwrapTSNode, walkBlockDeclarations, walkFunctionParams, walkIdentifiers, warnDeprecation };
6694
+ export { BASE_TRANSITION, BindingTypes, CAMELIZE, CAPITALIZE, CREATE_BLOCK, CREATE_COMMENT, CREATE_ELEMENT_BLOCK, CREATE_ELEMENT_VNODE, CREATE_SLOTS, CREATE_STATIC, CREATE_TEXT, CREATE_VNODE, CompilerDeprecationTypes, ConstantTypes, DOMDirectiveTransforms, DOMErrorCodes, DOMErrorMessages, DOMNodeTransforms, ElementTypes, ErrorCodes, FRAGMENT, GUARD_REACTIVE_PROPS, IS_MEMO_SAME, IS_REF, KEEP_ALIVE, MERGE_PROPS, NORMALIZE_CLASS, NORMALIZE_PROPS, NORMALIZE_STYLE, Namespaces, NewlineType, NodeTypes, OPEN_BLOCK, POP_SCOPE_ID, PUSH_SCOPE_ID, RENDER_LIST, RENDER_SLOT, RESOLVE_COMPONENT, RESOLVE_DIRECTIVE, RESOLVE_DYNAMIC_COMPONENT, RESOLVE_FILTER, SET_BLOCK_TRACKING, SUSPENSE, TELEPORT, TO_DISPLAY_STRING, TO_HANDLERS, TO_HANDLER_KEY, TRANSITION, TRANSITION_GROUP, TS_NODE_TYPES, UNREF, V_MODEL_CHECKBOX, V_MODEL_DYNAMIC, V_MODEL_RADIO, V_MODEL_SELECT, V_MODEL_TEXT, V_ON_WITH_KEYS, V_ON_WITH_MODIFIERS, V_SHOW, WITH_CTX, WITH_DIRECTIVES, WITH_MEMO, advancePositionWithClone, advancePositionWithMutation, assert, baseCompile, baseParse, buildDirectiveArgs, buildProps, buildSlots, checkCompatEnabled, compile, convertToBlock, createArrayExpression, createAssignmentExpression, createBlockStatement, createCacheExpression, createCallExpression, createCompilerError, createCompoundExpression, createConditionalExpression, createDOMCompilerError, createForLoopParams, createFunctionExpression, createIfStatement, createInterpolation, createObjectExpression, createObjectProperty, createReturnStatement, createRoot, createSequenceExpression, createSimpleExpression, createStructuralDirectiveTransform, createTemplateLiteral, createTransformContext, createVNodeCall, defaultOnError, defaultOnWarn, errorMessages, extractIdentifiers, findDir, findProp, forAliasRE, generate, generateCodeFrame, getBaseTransformPreset, getConstantType, getMemoedVNodeCall, getSelfName, getVNodeBlockHelper, getVNodeHelper, hasDynamicKeyVBind, hasScopeRef, helperNameMap, injectProp, isConstantNode, isCoreComponent, isFnExpression, isFnExpressionBrowser, isFnExpressionNode, isFunctionType, isInDestructureAssignment, isInNewExpression, isLiteralWhitelisted, isMemberExpression, isMemberExpressionBrowser, isMemberExpressionNode, isReferencedIdentifier, isSimpleIdentifier, isSlotOutlet, isStaticArgOf, isStaticExp, isStaticNode, isStaticProperty, isStaticPropertyKey, isTemplateNode, isText$1 as isText, isVPre, isVSlot, isValidHTMLNesting, locStub, noopDirectiveTransform, parse, parserOptions, postTransformTransition, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, resolveModifiers, stringifyExpression, toValidAssetId, trackSlotScopes, trackVForSlotScopes, transform, transformBind, transformElement, transformExpression, transformModel$1 as transformModel, transformOn$1 as transformOn, transformStyle, transformVBindShorthand, traverseNode, unwrapTSNode, validFirstIdentCharRE, walkBlockDeclarations, walkFunctionParams, walkIdentifiers, warnDeprecation };