@vue/compiler-core 3.5.0-alpha.1 → 3.5.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-core v3.5.0-alpha.1
2
+ * @vue/compiler-core v3.5.0-alpha.3
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -180,8 +180,8 @@ const ConstantTypes = {
180
180
  "0": "NOT_CONSTANT",
181
181
  "CAN_SKIP_PATCH": 1,
182
182
  "1": "CAN_SKIP_PATCH",
183
- "CAN_HOIST": 2,
184
- "2": "CAN_HOIST",
183
+ "CAN_CACHE": 2,
184
+ "2": "CAN_CACHE",
185
185
  "CAN_STRINGIFY": 3,
186
186
  "3": "CAN_STRINGIFY"
187
187
  };
@@ -200,7 +200,7 @@ function createRoot(children, source = "") {
200
200
  directives: [],
201
201
  hoists: [],
202
202
  imports: [],
203
- cached: 0,
203
+ cached: [],
204
204
  temps: 0,
205
205
  codegenNode: void 0,
206
206
  loc: locStub
@@ -305,12 +305,13 @@ function createConditionalExpression(test, consequent, alternate, newline = true
305
305
  loc: locStub
306
306
  };
307
307
  }
308
- function createCacheExpression(index, value, isVNode = false) {
308
+ function createCacheExpression(index, value, needPauseTracking = false) {
309
309
  return {
310
310
  type: 20,
311
311
  index,
312
312
  value,
313
- isVNode,
313
+ needPauseTracking,
314
+ needArraySpread: false,
314
315
  loc: locStub
315
316
  };
316
317
  }
@@ -1310,8 +1311,7 @@ function warnDeprecation(key, context, loc, ...args) {
1310
1311
  Details: ${link}` : ``}`;
1311
1312
  const err = new SyntaxError(msg);
1312
1313
  err.code = key;
1313
- if (loc)
1314
- err.loc = loc;
1314
+ if (loc) err.loc = loc;
1315
1315
  context.onWarn(err);
1316
1316
  }
1317
1317
 
@@ -1514,7 +1514,8 @@ function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [
1514
1514
  if (includeAll || isRefed && !isLocal) {
1515
1515
  onIdentifier(node, parent, parentStack, isRefed, isLocal);
1516
1516
  }
1517
- } else if (node.type === "ObjectProperty" && (parent == null ? void 0 : parent.type) === "ObjectPattern") {
1517
+ } else if (node.type === "ObjectProperty" && // eslint-disable-next-line no-restricted-syntax
1518
+ (parent == null ? void 0 : parent.type) === "ObjectPattern") {
1518
1519
  node.inPattern = true;
1519
1520
  } else if (isFunctionType(node)) {
1520
1521
  if (node.scopeIds) {
@@ -1605,16 +1606,14 @@ function walkFunctionParams(node, onIdent) {
1605
1606
  function walkBlockDeclarations(block, onIdent) {
1606
1607
  for (const stmt of block.body) {
1607
1608
  if (stmt.type === "VariableDeclaration") {
1608
- if (stmt.declare)
1609
- continue;
1609
+ if (stmt.declare) continue;
1610
1610
  for (const decl of stmt.declarations) {
1611
1611
  for (const id of extractIdentifiers(decl.id)) {
1612
1612
  onIdent(id);
1613
1613
  }
1614
1614
  }
1615
1615
  } else if (stmt.type === "FunctionDeclaration" || stmt.type === "ClassDeclaration") {
1616
- if (stmt.declare || !stmt.id)
1617
- continue;
1616
+ if (stmt.declare || !stmt.id) continue;
1618
1617
  onIdent(stmt.id);
1619
1618
  } else if (stmt.type === "ForOfStatement" || stmt.type === "ForInStatement" || stmt.type === "ForStatement") {
1620
1619
  const variable = stmt.type === "ForStatement" ? stmt.init : stmt.left;
@@ -1651,8 +1650,7 @@ function extractIdentifiers(param, nodes = []) {
1651
1650
  break;
1652
1651
  case "ArrayPattern":
1653
1652
  param.elements.forEach((element) => {
1654
- if (element)
1655
- extractIdentifiers(element, nodes);
1653
+ if (element) extractIdentifiers(element, nodes);
1656
1654
  });
1657
1655
  break;
1658
1656
  case "RestElement":
@@ -1805,7 +1803,7 @@ function isCoreComponent(tag) {
1805
1803
  return BASE_TRANSITION;
1806
1804
  }
1807
1805
  }
1808
- const nonIdentifierRE = /^\d|[^\$\w]/;
1806
+ const nonIdentifierRE = /^\d|[^\$\w\xA0-\uFFFF]/;
1809
1807
  const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
1810
1808
  const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
1811
1809
  const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
@@ -1926,8 +1924,7 @@ function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
1926
1924
  for (let i = 0; i < node.props.length; i++) {
1927
1925
  const p = node.props[i];
1928
1926
  if (p.type === 6) {
1929
- if (dynamicOnly)
1930
- continue;
1927
+ if (dynamicOnly) continue;
1931
1928
  if (p.name === name && (p.value || allowEmpty)) {
1932
1929
  return p;
1933
1930
  }
@@ -2079,6 +2076,7 @@ function hasScopeRef(node, ids) {
2079
2076
  return hasScopeRef(node.content, ids);
2080
2077
  case 2:
2081
2078
  case 3:
2079
+ case 20:
2082
2080
  return false;
2083
2081
  default:
2084
2082
  return false;
@@ -2091,7 +2089,7 @@ function getMemoedVNodeCall(node) {
2091
2089
  return node;
2092
2090
  }
2093
2091
  }
2094
- const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
2092
+ const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+(\S[\s\S]*)/;
2095
2093
 
2096
2094
  const defaultParserOptions = {
2097
2095
  parseMode: "base",
@@ -2191,11 +2189,10 @@ const tokenizer = new Tokenizer(stack, {
2191
2189
  }
2192
2190
  },
2193
2191
  onselfclosingtag(end) {
2194
- var _a;
2195
2192
  const name = currentOpenTag.tag;
2196
2193
  currentOpenTag.isSelfClosing = true;
2197
2194
  endOpenTag(end);
2198
- if (((_a = stack[0]) == null ? void 0 : _a.tag) === name) {
2195
+ if (stack[0] && stack[0].tag === name) {
2199
2196
  onCloseTag(stack.shift(), end);
2200
2197
  }
2201
2198
  },
@@ -2245,8 +2242,7 @@ const tokenizer = new Tokenizer(stack, {
2245
2242
  }
2246
2243
  },
2247
2244
  ondirarg(start, end) {
2248
- if (start === end)
2249
- return;
2245
+ if (start === end) return;
2250
2246
  const arg = getSlice(start, end);
2251
2247
  if (inVPre) {
2252
2248
  currentProp.name += arg;
@@ -2278,14 +2274,12 @@ const tokenizer = new Tokenizer(stack, {
2278
2274
  },
2279
2275
  onattribdata(start, end) {
2280
2276
  currentAttrValue += getSlice(start, end);
2281
- if (currentAttrStartIndex < 0)
2282
- currentAttrStartIndex = start;
2277
+ if (currentAttrStartIndex < 0) currentAttrStartIndex = start;
2283
2278
  currentAttrEndIndex = end;
2284
2279
  },
2285
2280
  onattribentity(char, start, end) {
2286
2281
  currentAttrValue += char;
2287
- if (currentAttrStartIndex < 0)
2288
- currentAttrStartIndex = start;
2282
+ if (currentAttrStartIndex < 0) currentAttrStartIndex = start;
2289
2283
  currentAttrEndIndex = end;
2290
2284
  },
2291
2285
  onattribnameend(end) {
@@ -2435,8 +2429,7 @@ function parseForExpression(input) {
2435
2429
  const loc = input.loc;
2436
2430
  const exp = input.content;
2437
2431
  const inMatch = exp.match(forAliasRE);
2438
- if (!inMatch)
2439
- return;
2432
+ if (!inMatch) return;
2440
2433
  const [, LHS, RHS] = inMatch;
2441
2434
  const createAliasExpression = (content, offset, asParam = false) => {
2442
2435
  const start = loc.start.offset + offset;
@@ -2511,7 +2504,7 @@ function endOpenTag(end) {
2511
2504
  function onText(content, start, end) {
2512
2505
  const parent = stack[0] || currentRoot;
2513
2506
  const lastNode = parent.children[parent.children.length - 1];
2514
- if ((lastNode == null ? void 0 : lastNode.type) === 2) {
2507
+ if (lastNode && lastNode.type === 2) {
2515
2508
  lastNode.content += content;
2516
2509
  setLocEnd(lastNode.loc, end);
2517
2510
  } else {
@@ -2593,14 +2586,12 @@ function onCloseTag(el, end, isImplied = false) {
2593
2586
  }
2594
2587
  function lookAhead(index, c) {
2595
2588
  let i = index;
2596
- while (currentInput.charCodeAt(i) !== c && i < currentInput.length - 1)
2597
- i++;
2589
+ while (currentInput.charCodeAt(i) !== c && i < currentInput.length - 1) i++;
2598
2590
  return i;
2599
2591
  }
2600
2592
  function backTrack(index, c) {
2601
2593
  let i = index;
2602
- while (currentInput.charCodeAt(i) !== c && i >= 0)
2603
- i--;
2594
+ while (currentInput.charCodeAt(i) !== c && i >= 0) i--;
2604
2595
  return i;
2605
2596
  }
2606
2597
  const specialTemplateDir = /* @__PURE__ */ new Set(["if", "else", "else-if", "for", "slot"]);
@@ -2615,11 +2606,10 @@ function isFragmentTemplate({ tag, props }) {
2615
2606
  return false;
2616
2607
  }
2617
2608
  function isComponent({ tag, props }) {
2618
- var _a;
2619
2609
  if (currentOptions.isCustomElement(tag)) {
2620
2610
  return false;
2621
2611
  }
2622
- if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || ((_a = currentOptions.isBuiltInComponent) == null ? void 0 : _a.call(currentOptions, tag)) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) {
2612
+ if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || currentOptions.isBuiltInComponent && currentOptions.isBuiltInComponent(tag) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) {
2623
2613
  return true;
2624
2614
  }
2625
2615
  for (let i = 0; i < props.length; i++) {
@@ -2652,7 +2642,6 @@ function isUpperCase(c) {
2652
2642
  }
2653
2643
  const windowsNewlineRE = /\r\n/g;
2654
2644
  function condenseWhitespace(nodes, tag) {
2655
- var _a, _b;
2656
2645
  const shouldCondense = currentOptions.whitespace !== "preserve";
2657
2646
  let removedWhitespace = false;
2658
2647
  for (let i = 0; i < nodes.length; i++) {
@@ -2660,8 +2649,8 @@ function condenseWhitespace(nodes, tag) {
2660
2649
  if (node.type === 2) {
2661
2650
  if (!inPre) {
2662
2651
  if (isAllWhitespace(node.content)) {
2663
- const prev = (_a = nodes[i - 1]) == null ? void 0 : _a.type;
2664
- const next = (_b = nodes[i + 1]) == null ? void 0 : _b.type;
2652
+ const prev = nodes[i - 1] && nodes[i - 1].type;
2653
+ const next = nodes[i + 1] && nodes[i + 1].type;
2665
2654
  if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
2666
2655
  removedWhitespace = true;
2667
2656
  nodes[i] = null;
@@ -2814,7 +2803,7 @@ function baseParse(input, options) {
2814
2803
  }
2815
2804
  tokenizer.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
2816
2805
  tokenizer.inXML = currentOptions.ns === 1 || currentOptions.ns === 2;
2817
- const delimiters = options == null ? void 0 : options.delimiters;
2806
+ const delimiters = options && options.delimiters;
2818
2807
  if (delimiters) {
2819
2808
  tokenizer.delimiterOpen = toCharCodes(delimiters[0]);
2820
2809
  tokenizer.delimiterClose = toCharCodes(delimiters[1]);
@@ -2827,9 +2816,10 @@ function baseParse(input, options) {
2827
2816
  return root;
2828
2817
  }
2829
2818
 
2830
- function hoistStatic(root, context) {
2819
+ function cacheStatic(root, context) {
2831
2820
  walk(
2832
2821
  root,
2822
+ void 0,
2833
2823
  context,
2834
2824
  // Root node is unfortunately non-hoistable due to potential parent
2835
2825
  // fallthrough attributes.
@@ -2840,26 +2830,24 @@ function isSingleElementRoot(root, child) {
2840
2830
  const { children } = root;
2841
2831
  return children.length === 1 && child.type === 1 && !isSlotOutlet(child);
2842
2832
  }
2843
- function walk(node, context, doNotHoistNode = false) {
2833
+ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
2844
2834
  const { children } = node;
2845
- const originalCount = children.length;
2846
- let hoistedCount = 0;
2835
+ const toCache = [];
2847
2836
  for (let i = 0; i < children.length; i++) {
2848
2837
  const child = children[i];
2849
2838
  if (child.type === 1 && child.tagType === 0) {
2850
2839
  const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
2851
2840
  if (constantType > 0) {
2852
2841
  if (constantType >= 2) {
2853
- child.codegenNode.patchFlag = -1 + (``);
2854
- child.codegenNode = context.hoist(child.codegenNode);
2855
- hoistedCount++;
2842
+ child.codegenNode.patchFlag = -1;
2843
+ toCache.push(child);
2856
2844
  continue;
2857
2845
  }
2858
2846
  } else {
2859
2847
  const codegenNode = child.codegenNode;
2860
2848
  if (codegenNode.type === 13) {
2861
- const flag = getPatchFlag(codegenNode);
2862
- if ((!flag || flag === 512 || flag === 1) && getGeneratedPropsConstantType(child, context) >= 2) {
2849
+ const flag = codegenNode.patchFlag;
2850
+ if ((flag === void 0 || flag === 512 || flag === 1) && getGeneratedPropsConstantType(child, context) >= 2) {
2863
2851
  const props = getNodeProps(child);
2864
2852
  if (props) {
2865
2853
  codegenNode.props = context.hoist(props);
@@ -2870,39 +2858,84 @@ function walk(node, context, doNotHoistNode = false) {
2870
2858
  }
2871
2859
  }
2872
2860
  }
2861
+ } else if (child.type === 12) {
2862
+ const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
2863
+ if (constantType >= 2) {
2864
+ toCache.push(child);
2865
+ continue;
2866
+ }
2873
2867
  }
2874
2868
  if (child.type === 1) {
2875
2869
  const isComponent = child.tagType === 1;
2876
2870
  if (isComponent) {
2877
2871
  context.scopes.vSlot++;
2878
2872
  }
2879
- walk(child, context);
2873
+ walk(child, node, context, false, inFor);
2880
2874
  if (isComponent) {
2881
2875
  context.scopes.vSlot--;
2882
2876
  }
2883
2877
  } else if (child.type === 11) {
2884
- walk(child, context, child.children.length === 1);
2878
+ walk(child, node, context, child.children.length === 1, true);
2885
2879
  } else if (child.type === 9) {
2886
2880
  for (let i2 = 0; i2 < child.branches.length; i2++) {
2887
2881
  walk(
2888
2882
  child.branches[i2],
2883
+ node,
2889
2884
  context,
2890
- child.branches[i2].children.length === 1
2885
+ child.branches[i2].children.length === 1,
2886
+ inFor
2891
2887
  );
2892
2888
  }
2893
2889
  }
2894
2890
  }
2895
- if (hoistedCount && context.transformHoist) {
2896
- context.transformHoist(children, context, node);
2891
+ let cachedAsArray = false;
2892
+ if (toCache.length === children.length && node.type === 1) {
2893
+ if (node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && shared.isArray(node.codegenNode.children)) {
2894
+ node.codegenNode.children = getCacheExpression(
2895
+ createArrayExpression(node.codegenNode.children)
2896
+ );
2897
+ cachedAsArray = true;
2898
+ } else if (node.tagType === 1 && node.codegenNode && node.codegenNode.type === 13 && node.codegenNode.children && !shared.isArray(node.codegenNode.children) && node.codegenNode.children.type === 15) {
2899
+ const slot = getSlotNode(node.codegenNode, "default");
2900
+ if (slot) {
2901
+ slot.returns = getCacheExpression(
2902
+ createArrayExpression(slot.returns)
2903
+ );
2904
+ cachedAsArray = true;
2905
+ }
2906
+ } else if (node.tagType === 3 && parent && parent.type === 1 && parent.tagType === 1 && parent.codegenNode && parent.codegenNode.type === 13 && parent.codegenNode.children && !shared.isArray(parent.codegenNode.children) && parent.codegenNode.children.type === 15) {
2907
+ const slotName = findDir(node, "slot", true);
2908
+ const slot = slotName && slotName.arg && getSlotNode(parent.codegenNode, slotName.arg);
2909
+ if (slot) {
2910
+ slot.returns = getCacheExpression(
2911
+ createArrayExpression(slot.returns)
2912
+ );
2913
+ cachedAsArray = true;
2914
+ }
2915
+ }
2897
2916
  }
2898
- if (hoistedCount && hoistedCount === originalCount && node.type === 1 && node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && shared.isArray(node.codegenNode.children)) {
2899
- const hoisted = context.hoist(
2900
- createArrayExpression(node.codegenNode.children)
2901
- );
2902
- if (context.hmr) {
2903
- hoisted.content = `[...${hoisted.content}]`;
2917
+ if (!cachedAsArray) {
2918
+ for (const child of toCache) {
2919
+ child.codegenNode = context.cache(child.codegenNode);
2904
2920
  }
2905
- node.codegenNode.children = hoisted;
2921
+ }
2922
+ function getCacheExpression(value) {
2923
+ const exp = context.cache(value);
2924
+ if (inFor && context.hmr) {
2925
+ exp.needArraySpread = true;
2926
+ }
2927
+ return exp;
2928
+ }
2929
+ function getSlotNode(node2, name) {
2930
+ if (node2.children && !shared.isArray(node2.children) && node2.children.type === 15) {
2931
+ const slot = node2.children.properties.find(
2932
+ (p) => p.key === name || p.key.content === name
2933
+ );
2934
+ return slot && slot.value;
2935
+ }
2936
+ }
2937
+ if (toCache.length && context.transformHoist) {
2938
+ context.transformHoist(children, context, node);
2906
2939
  }
2907
2940
  }
2908
2941
  function getConstantType(node, context) {
@@ -2920,11 +2953,10 @@ function getConstantType(node, context) {
2920
2953
  if (codegenNode.type !== 13) {
2921
2954
  return 0;
2922
2955
  }
2923
- if (codegenNode.isBlock && node.tag !== "svg" && node.tag !== "foreignObject") {
2956
+ if (codegenNode.isBlock && node.tag !== "svg" && node.tag !== "foreignObject" && node.tag !== "math") {
2924
2957
  return 0;
2925
2958
  }
2926
- const flag = getPatchFlag(codegenNode);
2927
- if (!flag) {
2959
+ if (codegenNode.patchFlag === void 0) {
2928
2960
  let returnType2 = 3;
2929
2961
  const generatedPropsType = getGeneratedPropsConstantType(node, context);
2930
2962
  if (generatedPropsType === 0) {
@@ -3007,6 +3039,8 @@ function getConstantType(node, context) {
3007
3039
  }
3008
3040
  }
3009
3041
  return returnType;
3042
+ case 20:
3043
+ return 2;
3010
3044
  default:
3011
3045
  return 0;
3012
3046
  }
@@ -3066,15 +3100,11 @@ function getNodeProps(node) {
3066
3100
  return codegenNode.props;
3067
3101
  }
3068
3102
  }
3069
- function getPatchFlag(node) {
3070
- const flag = node.patchFlag;
3071
- return flag ? parseInt(flag, 10) : void 0;
3072
- }
3073
3103
 
3074
3104
  function createTransformContext(root, {
3075
3105
  filename = "",
3076
3106
  prefixIdentifiers = false,
3077
- hoistStatic: hoistStatic2 = false,
3107
+ hoistStatic = false,
3078
3108
  hmr = false,
3079
3109
  cacheHandlers = false,
3080
3110
  nodeTransforms = [],
@@ -3101,7 +3131,7 @@ function createTransformContext(root, {
3101
3131
  filename,
3102
3132
  selfName: nameMatch && shared.capitalize(shared.camelize(nameMatch[1])),
3103
3133
  prefixIdentifiers,
3104
- hoistStatic: hoistStatic2,
3134
+ hoistStatic,
3105
3135
  hmr,
3106
3136
  cacheHandlers,
3107
3137
  nodeTransforms,
@@ -3128,9 +3158,9 @@ function createTransformContext(root, {
3128
3158
  directives: /* @__PURE__ */ new Set(),
3129
3159
  hoists: [],
3130
3160
  imports: [],
3161
+ cached: [],
3131
3162
  constantCache: /* @__PURE__ */ new WeakMap(),
3132
3163
  temps: 0,
3133
- cached: 0,
3134
3164
  identifiers: /* @__PURE__ */ Object.create(null),
3135
3165
  scopes: {
3136
3166
  vFor: 0,
@@ -3204,8 +3234,7 @@ function createTransformContext(root, {
3204
3234
  }
3205
3235
  },
3206
3236
  hoist(exp) {
3207
- if (shared.isString(exp))
3208
- exp = createSimpleExpression(exp);
3237
+ if (shared.isString(exp)) exp = createSimpleExpression(exp);
3209
3238
  context.hoists.push(exp);
3210
3239
  const identifier = createSimpleExpression(
3211
3240
  `_hoisted_${context.hoists.length}`,
@@ -3217,7 +3246,13 @@ function createTransformContext(root, {
3217
3246
  return identifier;
3218
3247
  },
3219
3248
  cache(exp, isVNode = false) {
3220
- return createCacheExpression(context.cached++, exp, isVNode);
3249
+ const cacheExp = createCacheExpression(
3250
+ context.cached.length,
3251
+ exp,
3252
+ isVNode
3253
+ );
3254
+ context.cached.push(cacheExp);
3255
+ return cacheExp;
3221
3256
  }
3222
3257
  };
3223
3258
  {
@@ -3239,7 +3274,7 @@ function transform(root, options) {
3239
3274
  const context = createTransformContext(root, options);
3240
3275
  traverseNode(root, context);
3241
3276
  if (options.hoistStatic) {
3242
- hoistStatic(root, context);
3277
+ cacheStatic(root, context);
3243
3278
  }
3244
3279
  if (!options.ssr) {
3245
3280
  createRootCodegen(root, context);
@@ -3278,7 +3313,7 @@ function createRootCodegen(root, context) {
3278
3313
  helper(FRAGMENT),
3279
3314
  void 0,
3280
3315
  root.children,
3281
- patchFlag + (``),
3316
+ patchFlag,
3282
3317
  void 0,
3283
3318
  void 0,
3284
3319
  true,
@@ -3294,8 +3329,7 @@ function traverseChildren(parent, context) {
3294
3329
  };
3295
3330
  for (; i < parent.children.length; i++) {
3296
3331
  const child = parent.children[i];
3297
- if (shared.isString(child))
3298
- continue;
3332
+ if (shared.isString(child)) continue;
3299
3333
  context.grandParent = context.parent;
3300
3334
  context.parent = parent;
3301
3335
  context.childIndex = i;
@@ -3366,8 +3400,7 @@ function createStructuralDirectiveTransform(name, fn) {
3366
3400
  props.splice(i, 1);
3367
3401
  i--;
3368
3402
  const onExit = fn(node, prop, context);
3369
- if (onExit)
3370
- exitFns.push(onExit);
3403
+ if (onExit) exitFns.push(onExit);
3371
3404
  }
3372
3405
  }
3373
3406
  return exitFns;
@@ -3466,8 +3499,7 @@ function createCodegenContext(ast, {
3466
3499
  }
3467
3500
  function addMapping(loc, name = null) {
3468
3501
  const { _names, _mappings } = context.map;
3469
- if (name !== null && !_names.has(name))
3470
- _names.add(name);
3502
+ if (name !== null && !_names.has(name)) _names.add(name);
3471
3503
  _mappings.add({
3472
3504
  originalLine: loc.line,
3473
3505
  originalColumn: loc.column - 1,
@@ -3487,8 +3519,7 @@ function createCodegenContext(ast, {
3487
3519
  }
3488
3520
  function generate(ast, options = {}) {
3489
3521
  const context = createCodegenContext(ast, options);
3490
- if (options.onContextCreated)
3491
- options.onContextCreated(context);
3522
+ if (options.onContextCreated) options.onContextCreated(context);
3492
3523
  const {
3493
3524
  mode,
3494
3525
  push,
@@ -3637,10 +3668,6 @@ function genModulePreamble(ast, context, genScopeId, inline) {
3637
3668
  runtimeModuleName,
3638
3669
  ssrRuntimeModuleName
3639
3670
  } = context;
3640
- if (genScopeId && ast.hoists.length) {
3641
- ast.helpers.add(PUSH_SCOPE_ID);
3642
- ast.helpers.add(POP_SCOPE_ID);
3643
- }
3644
3671
  if (ast.helpers.size) {
3645
3672
  const helpers = Array.from(ast.helpers);
3646
3673
  if (optimizeImports) {
@@ -3704,28 +3731,13 @@ function genHoists(hoists, context) {
3704
3731
  return;
3705
3732
  }
3706
3733
  context.pure = true;
3707
- const { push, newline, helper, scopeId, mode } = context;
3708
- const genScopeId = scopeId != null && mode !== "function";
3734
+ const { push, newline } = context;
3709
3735
  newline();
3710
- if (genScopeId) {
3711
- push(
3712
- `const _withScopeId = n => (${helper(
3713
- PUSH_SCOPE_ID
3714
- )}("${scopeId}"),n=n(),${helper(POP_SCOPE_ID)}(),n)`
3715
- );
3716
- newline();
3717
- }
3718
3736
  for (let i = 0; i < hoists.length; i++) {
3719
3737
  const exp = hoists[i];
3720
3738
  if (exp) {
3721
- const needScopeIdWrapper = genScopeId && exp.type === 13;
3722
- push(
3723
- `const _hoisted_${i + 1} = ${needScopeIdWrapper ? `${PURE_ANNOTATION} _withScopeId(() => ` : ``}`
3724
- );
3739
+ push(`const _hoisted_${i + 1} = `);
3725
3740
  genNode(exp, context);
3726
- if (needScopeIdWrapper) {
3727
- push(`)`);
3728
- }
3729
3741
  newline();
3730
3742
  }
3731
3743
  }
@@ -3861,8 +3873,7 @@ function genExpression(node, context) {
3861
3873
  }
3862
3874
  function genInterpolation(node, context) {
3863
3875
  const { push, helper, pure } = context;
3864
- if (pure)
3865
- push(PURE_ANNOTATION);
3876
+ if (pure) push(PURE_ANNOTATION);
3866
3877
  push(`${helper(TO_DISPLAY_STRING)}(`);
3867
3878
  genNode(node.content, context);
3868
3879
  push(`)`);
@@ -3914,6 +3925,12 @@ function genVNodeCall(node, context) {
3914
3925
  disableTracking,
3915
3926
  isComponent
3916
3927
  } = node;
3928
+ let patchFlagString;
3929
+ if (patchFlag) {
3930
+ {
3931
+ patchFlagString = String(patchFlag);
3932
+ }
3933
+ }
3917
3934
  if (directives) {
3918
3935
  push(helper(WITH_DIRECTIVES) + `(`);
3919
3936
  }
@@ -3926,7 +3943,7 @@ function genVNodeCall(node, context) {
3926
3943
  const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent) : getVNodeHelper(context.inSSR, isComponent);
3927
3944
  push(helper(callHelper) + `(`, -2 /* None */, node);
3928
3945
  genNodeList(
3929
- genNullableArgs([tag, props, children, patchFlag, dynamicProps]),
3946
+ genNullableArgs([tag, props, children, patchFlagString, dynamicProps]),
3930
3947
  context
3931
3948
  );
3932
3949
  push(`)`);
@@ -3942,8 +3959,7 @@ function genVNodeCall(node, context) {
3942
3959
  function genNullableArgs(args) {
3943
3960
  let i = args.length;
3944
3961
  while (i--) {
3945
- if (args[i] != null)
3946
- break;
3962
+ if (args[i] != null) break;
3947
3963
  }
3948
3964
  return args.slice(0, i + 1).map((arg) => arg || `null`);
3949
3965
  }
@@ -4060,16 +4076,21 @@ function genConditionalExpression(node, context) {
4060
4076
  }
4061
4077
  function genCacheExpression(node, context) {
4062
4078
  const { push, helper, indent, deindent, newline } = context;
4079
+ const { needPauseTracking, needArraySpread } = node;
4080
+ if (needArraySpread) {
4081
+ push(`[...(`);
4082
+ }
4063
4083
  push(`_cache[${node.index}] || (`);
4064
- if (node.isVNode) {
4084
+ if (needPauseTracking) {
4065
4085
  indent();
4066
4086
  push(`${helper(SET_BLOCK_TRACKING)}(-1),`);
4067
4087
  newline();
4088
+ push(`(`);
4068
4089
  }
4069
4090
  push(`_cache[${node.index}] = `);
4070
4091
  genNode(node.value, context);
4071
- if (node.isVNode) {
4072
- push(`,`);
4092
+ if (needPauseTracking) {
4093
+ push(`).cacheIndex = ${node.index},`);
4073
4094
  newline();
4074
4095
  push(`${helper(SET_BLOCK_TRACKING)}(1),`);
4075
4096
  newline();
@@ -4077,6 +4098,9 @@ function genCacheExpression(node, context) {
4077
4098
  deindent();
4078
4099
  }
4079
4100
  push(`)`);
4101
+ if (needArraySpread) {
4102
+ push(`)]`);
4103
+ }
4080
4104
  }
4081
4105
  function genTemplateLiteral(node, context) {
4082
4106
  const { push, indent, deindent } = context;
@@ -4089,11 +4113,9 @@ function genTemplateLiteral(node, context) {
4089
4113
  push(e.replace(/(`|\$|\\)/g, "\\$1"), -3 /* Unknown */);
4090
4114
  } else {
4091
4115
  push("${");
4092
- if (multilines)
4093
- indent();
4116
+ if (multilines) indent();
4094
4117
  genNode(e, context);
4095
- if (multilines)
4096
- deindent();
4118
+ if (multilines) deindent();
4097
4119
  push("}");
4098
4120
  }
4099
4121
  }
@@ -4142,7 +4164,6 @@ function genReturnStatement({ returns }, context) {
4142
4164
  }
4143
4165
 
4144
4166
  const isLiteralWhitelisted = /* @__PURE__ */ shared.makeMap("true,false,null,this");
4145
- const constantBailRE = /\w\s*\(|\.[^\d]/;
4146
4167
  const transformExpression = (node, context) => {
4147
4168
  if (node.type === 5) {
4148
4169
  node.content = processExpression(
@@ -4237,7 +4258,6 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
4237
4258
  return `_ctx.${raw}`;
4238
4259
  };
4239
4260
  const rawExp = node.content;
4240
- const bailConstant = constantBailRE.test(rawExp);
4241
4261
  let ast = node.ast;
4242
4262
  if (ast === false) {
4243
4263
  return node;
@@ -4299,7 +4319,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
4299
4319
  node2.name = rewriteIdentifier(node2.name, parent, node2);
4300
4320
  ids.push(node2);
4301
4321
  } else {
4302
- if (!(needPrefix && isLocal) && !bailConstant) {
4322
+ if (!(needPrefix && isLocal) && (!parent || parent.type !== "CallExpression" && parent.type !== "NewExpression" && parent.type !== "MemberExpression")) {
4303
4323
  node2.isConstant = true;
4304
4324
  }
4305
4325
  ids.push(node2);
@@ -4343,7 +4363,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
4343
4363
  ret.ast = ast;
4344
4364
  } else {
4345
4365
  ret = node;
4346
- ret.constType = bailConstant ? 0 : 3;
4366
+ ret.constType = 3;
4347
4367
  }
4348
4368
  ret.identifiers = Object.keys(knownIds);
4349
4369
  return ret;
@@ -4463,8 +4483,7 @@ function processIf(node, dir, context, processCodegen) {
4463
4483
  sibling.branches.push(branch);
4464
4484
  const onExit = processCodegen && processCodegen(sibling, branch, false);
4465
4485
  traverseNode(branch, context);
4466
- if (onExit)
4467
- onExit();
4486
+ if (onExit) onExit();
4468
4487
  context.currentNode = null;
4469
4488
  } else {
4470
4489
  context.onError(
@@ -4529,7 +4548,7 @@ function createChildrenCodegenNode(branch, keyIndex, context) {
4529
4548
  helper(FRAGMENT),
4530
4549
  createObjectExpression([keyProperty]),
4531
4550
  children,
4532
- patchFlag + (``),
4551
+ patchFlag,
4533
4552
  void 0,
4534
4553
  void 0,
4535
4554
  true,
@@ -4582,6 +4601,90 @@ function getParentCondition(node) {
4582
4601
  }
4583
4602
  }
4584
4603
 
4604
+ const transformBind = (dir, _node, context) => {
4605
+ const { modifiers, loc } = dir;
4606
+ const arg = dir.arg;
4607
+ let { exp } = dir;
4608
+ if (exp && exp.type === 4 && !exp.content.trim()) {
4609
+ {
4610
+ context.onError(
4611
+ createCompilerError(34, loc)
4612
+ );
4613
+ return {
4614
+ props: [
4615
+ createObjectProperty(arg, createSimpleExpression("", true, loc))
4616
+ ]
4617
+ };
4618
+ }
4619
+ }
4620
+ if (!exp) {
4621
+ if (arg.type !== 4 || !arg.isStatic) {
4622
+ context.onError(
4623
+ createCompilerError(
4624
+ 52,
4625
+ arg.loc
4626
+ )
4627
+ );
4628
+ return {
4629
+ props: [
4630
+ createObjectProperty(arg, createSimpleExpression("", true, loc))
4631
+ ]
4632
+ };
4633
+ }
4634
+ transformBindShorthand(dir, context);
4635
+ exp = dir.exp;
4636
+ }
4637
+ if (arg.type !== 4) {
4638
+ arg.children.unshift(`(`);
4639
+ arg.children.push(`) || ""`);
4640
+ } else if (!arg.isStatic) {
4641
+ arg.content = `${arg.content} || ""`;
4642
+ }
4643
+ if (modifiers.includes("camel")) {
4644
+ if (arg.type === 4) {
4645
+ if (arg.isStatic) {
4646
+ arg.content = shared.camelize(arg.content);
4647
+ } else {
4648
+ arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
4649
+ }
4650
+ } else {
4651
+ arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
4652
+ arg.children.push(`)`);
4653
+ }
4654
+ }
4655
+ if (!context.inSSR) {
4656
+ if (modifiers.includes("prop")) {
4657
+ injectPrefix(arg, ".");
4658
+ }
4659
+ if (modifiers.includes("attr")) {
4660
+ injectPrefix(arg, "^");
4661
+ }
4662
+ }
4663
+ return {
4664
+ props: [createObjectProperty(arg, exp)]
4665
+ };
4666
+ };
4667
+ const transformBindShorthand = (dir, context) => {
4668
+ const arg = dir.arg;
4669
+ const propName = shared.camelize(arg.content);
4670
+ dir.exp = createSimpleExpression(propName, false, arg.loc);
4671
+ {
4672
+ dir.exp = processExpression(dir.exp, context);
4673
+ }
4674
+ };
4675
+ const injectPrefix = (arg, prefix) => {
4676
+ if (arg.type === 4) {
4677
+ if (arg.isStatic) {
4678
+ arg.content = prefix + arg.content;
4679
+ } else {
4680
+ arg.content = `\`${prefix}\${${arg.content}}\``;
4681
+ }
4682
+ } else {
4683
+ arg.children.unshift(`'${prefix}' + (`);
4684
+ arg.children.push(`)`);
4685
+ }
4686
+ };
4687
+
4585
4688
  const transformFor = createStructuralDirectiveTransform(
4586
4689
  "for",
4587
4690
  (node, dir, context) => {
@@ -4592,9 +4695,12 @@ const transformFor = createStructuralDirectiveTransform(
4592
4695
  ]);
4593
4696
  const isTemplate = isTemplateNode(node);
4594
4697
  const memo = findDir(node, "memo");
4595
- const keyProp = findProp(node, `key`);
4596
- const keyExp = keyProp && (keyProp.type === 6 ? createSimpleExpression(keyProp.value.content, true) : keyProp.exp);
4597
- const keyProperty = keyProp ? createObjectProperty(`key`, keyExp) : null;
4698
+ const keyProp = findProp(node, `key`, false, true);
4699
+ if (keyProp && keyProp.type === 7 && !keyProp.exp) {
4700
+ transformBindShorthand(keyProp, context);
4701
+ }
4702
+ const keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
4703
+ const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
4598
4704
  if (isTemplate) {
4599
4705
  if (memo) {
4600
4706
  memo.exp = processExpression(
@@ -4616,7 +4722,7 @@ const transformFor = createStructuralDirectiveTransform(
4616
4722
  helper(FRAGMENT),
4617
4723
  void 0,
4618
4724
  renderExp,
4619
- fragmentFlag + (``),
4725
+ fragmentFlag,
4620
4726
  void 0,
4621
4727
  void 0,
4622
4728
  true,
@@ -4656,7 +4762,7 @@ const transformFor = createStructuralDirectiveTransform(
4656
4762
  helper(FRAGMENT),
4657
4763
  keyProperty ? createObjectExpression([keyProperty]) : void 0,
4658
4764
  node.children,
4659
- 64 + (``),
4765
+ 64,
4660
4766
  void 0,
4661
4767
  void 0,
4662
4768
  true,
@@ -4710,8 +4816,9 @@ const transformFor = createStructuralDirectiveTransform(
4710
4816
  renderExp.arguments.push(
4711
4817
  loop,
4712
4818
  createSimpleExpression(`_cache`),
4713
- createSimpleExpression(String(context.cached++))
4819
+ createSimpleExpression(String(context.cached.length))
4714
4820
  );
4821
+ context.cached.push(null);
4715
4822
  } else {
4716
4823
  renderExp.arguments.push(
4717
4824
  createFunctionExpression(
@@ -4767,13 +4874,11 @@ function processFor(node, dir, context, processCodegen) {
4767
4874
  key && removeIdentifiers(key);
4768
4875
  index && removeIdentifiers(index);
4769
4876
  }
4770
- if (onExit)
4771
- onExit();
4877
+ if (onExit) onExit();
4772
4878
  };
4773
4879
  }
4774
4880
  function finalizeForParseResult(result, context) {
4775
- if (result.finalized)
4776
- return;
4881
+ if (result.finalized) return;
4777
4882
  if (context.prefixIdentifiers) {
4778
4883
  result.source = processExpression(
4779
4884
  result.source,
@@ -4809,8 +4914,7 @@ function createForLoopParams({ value, key, index }, memoArgs = []) {
4809
4914
  function createParamsList(args) {
4810
4915
  let i = args.length;
4811
4916
  while (i--) {
4812
- if (args[i])
4813
- break;
4917
+ if (args[i]) break;
4814
4918
  }
4815
4919
  return args.slice(0, i + 1).map((arg, i2) => arg || createSimpleExpression(`_`.repeat(i2 + 1), false));
4816
4920
  }
@@ -4942,9 +5046,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
4942
5046
  break;
4943
5047
  }
4944
5048
  }
4945
- if (prev && isTemplateNode(prev) && findDir(prev, "if")) {
4946
- children.splice(i, 1);
4947
- i--;
5049
+ if (prev && isTemplateNode(prev) && findDir(prev, /^(else-)?if$/)) {
4948
5050
  let conditional = dynamicSlots[dynamicSlots.length - 1];
4949
5051
  while (conditional.alternate.type === 19) {
4950
5052
  conditional = conditional.alternate;
@@ -5081,13 +5183,11 @@ function hasForwardedSlots(children) {
5081
5183
  }
5082
5184
  break;
5083
5185
  case 9:
5084
- if (hasForwardedSlots(child.branches))
5085
- return true;
5186
+ if (hasForwardedSlots(child.branches)) return true;
5086
5187
  break;
5087
5188
  case 10:
5088
5189
  case 11:
5089
- if (hasForwardedSlots(child.children))
5090
- return true;
5190
+ if (hasForwardedSlots(child.children)) return true;
5091
5191
  break;
5092
5192
  }
5093
5193
  }
@@ -5112,7 +5212,6 @@ const transformElement = (node, context) => {
5112
5212
  const isDynamicComponent = shared.isObject(vnodeTag) && vnodeTag.callee === RESOLVE_DYNAMIC_COMPONENT;
5113
5213
  let vnodeProps;
5114
5214
  let vnodeChildren;
5115
- let vnodePatchFlag;
5116
5215
  let patchFlag = 0;
5117
5216
  let vnodeDynamicProps;
5118
5217
  let dynamicPropNames;
@@ -5123,7 +5222,7 @@ const transformElement = (node, context) => {
5123
5222
  // updates inside get proper isSVG flag at runtime. (#639, #643)
5124
5223
  // This is technically web-specific, but splitting the logic out of core
5125
5224
  // leads to too much unnecessary complexity.
5126
- (tag === "svg" || tag === "foreignObject")
5225
+ (tag === "svg" || tag === "foreignObject" || tag === "math")
5127
5226
  );
5128
5227
  if (props.length > 0) {
5129
5228
  const propsBuildResult = buildProps(
@@ -5174,20 +5273,15 @@ const transformElement = (node, context) => {
5174
5273
  vnodeChildren = node.children;
5175
5274
  }
5176
5275
  }
5177
- if (patchFlag !== 0) {
5178
- {
5179
- vnodePatchFlag = String(patchFlag);
5180
- }
5181
- if (dynamicPropNames && dynamicPropNames.length) {
5182
- vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
5183
- }
5276
+ if (dynamicPropNames && dynamicPropNames.length) {
5277
+ vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
5184
5278
  }
5185
5279
  node.codegenNode = createVNodeCall(
5186
5280
  context,
5187
5281
  vnodeTag,
5188
5282
  vnodeProps,
5189
5283
  vnodeChildren,
5190
- vnodePatchFlag,
5284
+ patchFlag === 0 ? void 0 : patchFlag,
5191
5285
  vnodeDynamicProps,
5192
5286
  vnodeDirectives,
5193
5287
  !!shouldUseBlock,
@@ -5235,8 +5329,7 @@ function resolveComponentType(node, context, ssr = false) {
5235
5329
  }
5236
5330
  const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
5237
5331
  if (builtIn) {
5238
- if (!ssr)
5239
- context.helper(builtIn);
5332
+ if (!ssr) context.helper(builtIn);
5240
5333
  return builtIn;
5241
5334
  }
5242
5335
  {
@@ -5320,8 +5413,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
5320
5413
  );
5321
5414
  properties = [];
5322
5415
  }
5323
- if (arg)
5324
- mergeArgs.push(arg);
5416
+ if (arg) mergeArgs.push(arg);
5325
5417
  };
5326
5418
  const pushRefVForMarker = () => {
5327
5419
  if (context.scopes.vFor > 0) {
@@ -5652,8 +5744,7 @@ function buildDirectiveArgs(dir, context) {
5652
5744
  }
5653
5745
  }
5654
5746
  const { loc } = dir;
5655
- if (dir.exp)
5656
- dirArgs.push(dir.exp);
5747
+ if (dir.exp) dirArgs.push(dir.exp);
5657
5748
  if (dir.arg) {
5658
5749
  if (!dir.exp) {
5659
5750
  dirArgs.push(`void 0`);
@@ -5683,8 +5774,7 @@ function stringifyDynamicPropNames(props) {
5683
5774
  let propsNamesString = `[`;
5684
5775
  for (let i = 0, l = props.length; i < l; i++) {
5685
5776
  propsNamesString += JSON.stringify(props[i]);
5686
- if (i < l - 1)
5687
- propsNamesString += ", ";
5777
+ if (i < l - 1) propsNamesString += ", ";
5688
5778
  }
5689
5779
  return propsNamesString + `]`;
5690
5780
  }
@@ -5781,7 +5871,7 @@ function processSlotOutlet(node, context) {
5781
5871
  };
5782
5872
  }
5783
5873
 
5784
- const fnExpRE = /^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
5874
+ const fnExpRE = /^\s*(async\s*)?(\([^)]*?\)|[\w$_]+)\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
5785
5875
  const transformOn = (dir, node, context, augmentor) => {
5786
5876
  const { loc, modifiers, arg } = dir;
5787
5877
  if (!dir.exp && !modifiers.length) {
@@ -5881,85 +5971,6 @@ const transformOn = (dir, node, context, augmentor) => {
5881
5971
  return ret;
5882
5972
  };
5883
5973
 
5884
- const transformBind = (dir, _node, context) => {
5885
- const { modifiers, loc } = dir;
5886
- const arg = dir.arg;
5887
- let { exp } = dir;
5888
- if (exp && exp.type === 4 && !exp.content.trim()) {
5889
- {
5890
- context.onError(
5891
- createCompilerError(34, loc)
5892
- );
5893
- return {
5894
- props: [
5895
- createObjectProperty(arg, createSimpleExpression("", true, loc))
5896
- ]
5897
- };
5898
- }
5899
- }
5900
- if (!exp) {
5901
- if (arg.type !== 4 || !arg.isStatic) {
5902
- context.onError(
5903
- createCompilerError(
5904
- 52,
5905
- arg.loc
5906
- )
5907
- );
5908
- return {
5909
- props: [
5910
- createObjectProperty(arg, createSimpleExpression("", true, loc))
5911
- ]
5912
- };
5913
- }
5914
- const propName = shared.camelize(arg.content);
5915
- exp = dir.exp = createSimpleExpression(propName, false, arg.loc);
5916
- {
5917
- exp = dir.exp = processExpression(exp, context);
5918
- }
5919
- }
5920
- if (arg.type !== 4) {
5921
- arg.children.unshift(`(`);
5922
- arg.children.push(`) || ""`);
5923
- } else if (!arg.isStatic) {
5924
- arg.content = `${arg.content} || ""`;
5925
- }
5926
- if (modifiers.includes("camel")) {
5927
- if (arg.type === 4) {
5928
- if (arg.isStatic) {
5929
- arg.content = shared.camelize(arg.content);
5930
- } else {
5931
- arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
5932
- }
5933
- } else {
5934
- arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
5935
- arg.children.push(`)`);
5936
- }
5937
- }
5938
- if (!context.inSSR) {
5939
- if (modifiers.includes("prop")) {
5940
- injectPrefix(arg, ".");
5941
- }
5942
- if (modifiers.includes("attr")) {
5943
- injectPrefix(arg, "^");
5944
- }
5945
- }
5946
- return {
5947
- props: [createObjectProperty(arg, exp)]
5948
- };
5949
- };
5950
- const injectPrefix = (arg, prefix) => {
5951
- if (arg.type === 4) {
5952
- if (arg.isStatic) {
5953
- arg.content = prefix + arg.content;
5954
- } else {
5955
- arg.content = `\`${prefix}\${${arg.content}}\``;
5956
- }
5957
- } else {
5958
- arg.children.unshift(`'${prefix}' + (`);
5959
- arg.children.push(`)`);
5960
- }
5961
- };
5962
-
5963
5974
  const transformText = (node, context) => {
5964
5975
  if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
5965
5976
  return () => {
@@ -6147,8 +6158,7 @@ const transformFilter = (node, context) => {
6147
6158
  }
6148
6159
  if (node.type === 5) {
6149
6160
  rewriteFilter(node.content, context);
6150
- }
6151
- if (node.type === 1) {
6161
+ } else if (node.type === 1) {
6152
6162
  node.props.forEach((prop) => {
6153
6163
  if (prop.type === 7 && prop.name !== "for" && prop.exp) {
6154
6164
  rewriteFilter(prop.exp, context);
@@ -6162,8 +6172,7 @@ function rewriteFilter(node, context) {
6162
6172
  } else {
6163
6173
  for (let i = 0; i < node.children.length; i++) {
6164
6174
  const child = node.children[i];
6165
- if (typeof child !== "object")
6166
- continue;
6175
+ if (typeof child !== "object") continue;
6167
6176
  if (child.type === 4) {
6168
6177
  parseFilter(child, context);
6169
6178
  } else if (child.type === 8) {
@@ -6189,17 +6198,13 @@ function parseFilter(node, context) {
6189
6198
  prev = c;
6190
6199
  c = exp.charCodeAt(i);
6191
6200
  if (inSingle) {
6192
- if (c === 39 && prev !== 92)
6193
- inSingle = false;
6201
+ if (c === 39 && prev !== 92) inSingle = false;
6194
6202
  } else if (inDouble) {
6195
- if (c === 34 && prev !== 92)
6196
- inDouble = false;
6203
+ if (c === 34 && prev !== 92) inDouble = false;
6197
6204
  } else if (inTemplateString) {
6198
- if (c === 96 && prev !== 92)
6199
- inTemplateString = false;
6205
+ if (c === 96 && prev !== 92) inTemplateString = false;
6200
6206
  } else if (inRegex) {
6201
- if (c === 47 && prev !== 92)
6202
- inRegex = false;
6207
+ if (c === 47 && prev !== 92) inRegex = false;
6203
6208
  } else if (c === 124 && // pipe
6204
6209
  exp.charCodeAt(i + 1) !== 124 && exp.charCodeAt(i - 1) !== 124 && !curly && !square && !paren) {
6205
6210
  if (expression === void 0) {
@@ -6243,8 +6248,7 @@ function parseFilter(node, context) {
6243
6248
  let p;
6244
6249
  for (; j >= 0; j--) {
6245
6250
  p = exp.charAt(j);
6246
- if (p !== " ")
6247
- break;
6251
+ if (p !== " ") break;
6248
6252
  }
6249
6253
  if (!p || !validDivisionCharRE.test(p)) {
6250
6254
  inRegex = true;
@@ -6266,6 +6270,7 @@ function parseFilter(node, context) {
6266
6270
  expression = wrapFilter(expression, filters[i], context);
6267
6271
  }
6268
6272
  node.content = expression;
6273
+ node.ast = void 0;
6269
6274
  }
6270
6275
  }
6271
6276
  function wrapFilter(exp, filter, context) {
@@ -6300,8 +6305,9 @@ const transformMemo = (node, context) => {
6300
6305
  dir.exp,
6301
6306
  createFunctionExpression(void 0, codegenNode),
6302
6307
  `_cache`,
6303
- String(context.cached++)
6308
+ String(context.cached.length)
6304
6309
  ]);
6310
+ context.cached.push(null);
6305
6311
  }
6306
6312
  };
6307
6313
  }