@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
  }
@@ -1313,8 +1314,7 @@ function warnDeprecation(key, context, loc, ...args) {
1313
1314
  Details: ${link}` : ``}`;
1314
1315
  const err = new SyntaxError(msg);
1315
1316
  err.code = key;
1316
- if (loc)
1317
- err.loc = loc;
1317
+ if (loc) err.loc = loc;
1318
1318
  context.onWarn(err);
1319
1319
  }
1320
1320
 
@@ -1518,7 +1518,8 @@ function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [
1518
1518
  if (includeAll || isRefed && !isLocal) {
1519
1519
  onIdentifier(node, parent, parentStack, isRefed, isLocal);
1520
1520
  }
1521
- } else if (node.type === "ObjectProperty" && (parent == null ? void 0 : parent.type) === "ObjectPattern") {
1521
+ } else if (node.type === "ObjectProperty" && // eslint-disable-next-line no-restricted-syntax
1522
+ (parent == null ? void 0 : parent.type) === "ObjectPattern") {
1522
1523
  node.inPattern = true;
1523
1524
  } else if (isFunctionType(node)) {
1524
1525
  if (node.scopeIds) {
@@ -1609,16 +1610,14 @@ function walkFunctionParams(node, onIdent) {
1609
1610
  function walkBlockDeclarations(block, onIdent) {
1610
1611
  for (const stmt of block.body) {
1611
1612
  if (stmt.type === "VariableDeclaration") {
1612
- if (stmt.declare)
1613
- continue;
1613
+ if (stmt.declare) continue;
1614
1614
  for (const decl of stmt.declarations) {
1615
1615
  for (const id of extractIdentifiers(decl.id)) {
1616
1616
  onIdent(id);
1617
1617
  }
1618
1618
  }
1619
1619
  } else if (stmt.type === "FunctionDeclaration" || stmt.type === "ClassDeclaration") {
1620
- if (stmt.declare || !stmt.id)
1621
- continue;
1620
+ if (stmt.declare || !stmt.id) continue;
1622
1621
  onIdent(stmt.id);
1623
1622
  } else if (stmt.type === "ForOfStatement" || stmt.type === "ForInStatement" || stmt.type === "ForStatement") {
1624
1623
  const variable = stmt.type === "ForStatement" ? stmt.init : stmt.left;
@@ -1655,8 +1654,7 @@ function extractIdentifiers(param, nodes = []) {
1655
1654
  break;
1656
1655
  case "ArrayPattern":
1657
1656
  param.elements.forEach((element) => {
1658
- if (element)
1659
- extractIdentifiers(element, nodes);
1657
+ if (element) extractIdentifiers(element, nodes);
1660
1658
  });
1661
1659
  break;
1662
1660
  case "RestElement":
@@ -1809,7 +1807,7 @@ function isCoreComponent(tag) {
1809
1807
  return BASE_TRANSITION;
1810
1808
  }
1811
1809
  }
1812
- const nonIdentifierRE = /^\d|[^\$\w]/;
1810
+ const nonIdentifierRE = /^\d|[^\$\w\xA0-\uFFFF]/;
1813
1811
  const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
1814
1812
  const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
1815
1813
  const validIdentCharRE = /[\.\?\w$\xA0-\uFFFF]/;
@@ -1930,8 +1928,7 @@ function findProp(node, name, dynamicOnly = false, allowEmpty = false) {
1930
1928
  for (let i = 0; i < node.props.length; i++) {
1931
1929
  const p = node.props[i];
1932
1930
  if (p.type === 6) {
1933
- if (dynamicOnly)
1934
- continue;
1931
+ if (dynamicOnly) continue;
1935
1932
  if (p.name === name && (p.value || allowEmpty)) {
1936
1933
  return p;
1937
1934
  }
@@ -2083,6 +2080,7 @@ function hasScopeRef(node, ids) {
2083
2080
  return hasScopeRef(node.content, ids);
2084
2081
  case 2:
2085
2082
  case 3:
2083
+ case 20:
2086
2084
  return false;
2087
2085
  default:
2088
2086
  return false;
@@ -2095,7 +2093,7 @@ function getMemoedVNodeCall(node) {
2095
2093
  return node;
2096
2094
  }
2097
2095
  }
2098
- const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
2096
+ const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+(\S[\s\S]*)/;
2099
2097
 
2100
2098
  const defaultParserOptions = {
2101
2099
  parseMode: "base",
@@ -2195,11 +2193,10 @@ const tokenizer = new Tokenizer(stack, {
2195
2193
  }
2196
2194
  },
2197
2195
  onselfclosingtag(end) {
2198
- var _a;
2199
2196
  const name = currentOpenTag.tag;
2200
2197
  currentOpenTag.isSelfClosing = true;
2201
2198
  endOpenTag(end);
2202
- if (((_a = stack[0]) == null ? void 0 : _a.tag) === name) {
2199
+ if (stack[0] && stack[0].tag === name) {
2203
2200
  onCloseTag(stack.shift(), end);
2204
2201
  }
2205
2202
  },
@@ -2249,8 +2246,7 @@ const tokenizer = new Tokenizer(stack, {
2249
2246
  }
2250
2247
  },
2251
2248
  ondirarg(start, end) {
2252
- if (start === end)
2253
- return;
2249
+ if (start === end) return;
2254
2250
  const arg = getSlice(start, end);
2255
2251
  if (inVPre) {
2256
2252
  currentProp.name += arg;
@@ -2282,14 +2278,12 @@ const tokenizer = new Tokenizer(stack, {
2282
2278
  },
2283
2279
  onattribdata(start, end) {
2284
2280
  currentAttrValue += getSlice(start, end);
2285
- if (currentAttrStartIndex < 0)
2286
- currentAttrStartIndex = start;
2281
+ if (currentAttrStartIndex < 0) currentAttrStartIndex = start;
2287
2282
  currentAttrEndIndex = end;
2288
2283
  },
2289
2284
  onattribentity(char, start, end) {
2290
2285
  currentAttrValue += char;
2291
- if (currentAttrStartIndex < 0)
2292
- currentAttrStartIndex = start;
2286
+ if (currentAttrStartIndex < 0) currentAttrStartIndex = start;
2293
2287
  currentAttrEndIndex = end;
2294
2288
  },
2295
2289
  onattribnameend(end) {
@@ -2439,8 +2433,7 @@ function parseForExpression(input) {
2439
2433
  const loc = input.loc;
2440
2434
  const exp = input.content;
2441
2435
  const inMatch = exp.match(forAliasRE);
2442
- if (!inMatch)
2443
- return;
2436
+ if (!inMatch) return;
2444
2437
  const [, LHS, RHS] = inMatch;
2445
2438
  const createAliasExpression = (content, offset, asParam = false) => {
2446
2439
  const start = loc.start.offset + offset;
@@ -2515,7 +2508,7 @@ function endOpenTag(end) {
2515
2508
  function onText(content, start, end) {
2516
2509
  const parent = stack[0] || currentRoot;
2517
2510
  const lastNode = parent.children[parent.children.length - 1];
2518
- if ((lastNode == null ? void 0 : lastNode.type) === 2) {
2511
+ if (lastNode && lastNode.type === 2) {
2519
2512
  lastNode.content += content;
2520
2513
  setLocEnd(lastNode.loc, end);
2521
2514
  } else {
@@ -2627,14 +2620,12 @@ function onCloseTag(el, end, isImplied = false) {
2627
2620
  }
2628
2621
  function lookAhead(index, c) {
2629
2622
  let i = index;
2630
- while (currentInput.charCodeAt(i) !== c && i < currentInput.length - 1)
2631
- i++;
2623
+ while (currentInput.charCodeAt(i) !== c && i < currentInput.length - 1) i++;
2632
2624
  return i;
2633
2625
  }
2634
2626
  function backTrack(index, c) {
2635
2627
  let i = index;
2636
- while (currentInput.charCodeAt(i) !== c && i >= 0)
2637
- i--;
2628
+ while (currentInput.charCodeAt(i) !== c && i >= 0) i--;
2638
2629
  return i;
2639
2630
  }
2640
2631
  const specialTemplateDir = /* @__PURE__ */ new Set(["if", "else", "else-if", "for", "slot"]);
@@ -2649,11 +2640,10 @@ function isFragmentTemplate({ tag, props }) {
2649
2640
  return false;
2650
2641
  }
2651
2642
  function isComponent({ tag, props }) {
2652
- var _a;
2653
2643
  if (currentOptions.isCustomElement(tag)) {
2654
2644
  return false;
2655
2645
  }
2656
- if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || ((_a = currentOptions.isBuiltInComponent) == null ? void 0 : _a.call(currentOptions, tag)) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) {
2646
+ if (tag === "component" || isUpperCase(tag.charCodeAt(0)) || isCoreComponent(tag) || currentOptions.isBuiltInComponent && currentOptions.isBuiltInComponent(tag) || currentOptions.isNativeTag && !currentOptions.isNativeTag(tag)) {
2657
2647
  return true;
2658
2648
  }
2659
2649
  for (let i = 0; i < props.length; i++) {
@@ -2686,7 +2676,6 @@ function isUpperCase(c) {
2686
2676
  }
2687
2677
  const windowsNewlineRE = /\r\n/g;
2688
2678
  function condenseWhitespace(nodes, tag) {
2689
- var _a, _b;
2690
2679
  const shouldCondense = currentOptions.whitespace !== "preserve";
2691
2680
  let removedWhitespace = false;
2692
2681
  for (let i = 0; i < nodes.length; i++) {
@@ -2694,8 +2683,8 @@ function condenseWhitespace(nodes, tag) {
2694
2683
  if (node.type === 2) {
2695
2684
  if (!inPre) {
2696
2685
  if (isAllWhitespace(node.content)) {
2697
- const prev = (_a = nodes[i - 1]) == null ? void 0 : _a.type;
2698
- const next = (_b = nodes[i + 1]) == null ? void 0 : _b.type;
2686
+ const prev = nodes[i - 1] && nodes[i - 1].type;
2687
+ const next = nodes[i + 1] && nodes[i + 1].type;
2699
2688
  if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
2700
2689
  removedWhitespace = true;
2701
2690
  nodes[i] = null;
@@ -2855,7 +2844,7 @@ function baseParse(input, options) {
2855
2844
  }
2856
2845
  tokenizer.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
2857
2846
  tokenizer.inXML = currentOptions.ns === 1 || currentOptions.ns === 2;
2858
- const delimiters = options == null ? void 0 : options.delimiters;
2847
+ const delimiters = options && options.delimiters;
2859
2848
  if (delimiters) {
2860
2849
  tokenizer.delimiterOpen = toCharCodes(delimiters[0]);
2861
2850
  tokenizer.delimiterClose = toCharCodes(delimiters[1]);
@@ -2868,9 +2857,10 @@ function baseParse(input, options) {
2868
2857
  return root;
2869
2858
  }
2870
2859
 
2871
- function hoistStatic(root, context) {
2860
+ function cacheStatic(root, context) {
2872
2861
  walk(
2873
2862
  root,
2863
+ void 0,
2874
2864
  context,
2875
2865
  // Root node is unfortunately non-hoistable due to potential parent
2876
2866
  // fallthrough attributes.
@@ -2881,26 +2871,24 @@ function isSingleElementRoot(root, child) {
2881
2871
  const { children } = root;
2882
2872
  return children.length === 1 && child.type === 1 && !isSlotOutlet(child);
2883
2873
  }
2884
- function walk(node, context, doNotHoistNode = false) {
2874
+ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
2885
2875
  const { children } = node;
2886
- const originalCount = children.length;
2887
- let hoistedCount = 0;
2876
+ const toCache = [];
2888
2877
  for (let i = 0; i < children.length; i++) {
2889
2878
  const child = children[i];
2890
2879
  if (child.type === 1 && child.tagType === 0) {
2891
2880
  const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
2892
2881
  if (constantType > 0) {
2893
2882
  if (constantType >= 2) {
2894
- child.codegenNode.patchFlag = -1 + (` /* HOISTED */` );
2895
- child.codegenNode = context.hoist(child.codegenNode);
2896
- hoistedCount++;
2883
+ child.codegenNode.patchFlag = -1;
2884
+ toCache.push(child);
2897
2885
  continue;
2898
2886
  }
2899
2887
  } else {
2900
2888
  const codegenNode = child.codegenNode;
2901
2889
  if (codegenNode.type === 13) {
2902
- const flag = getPatchFlag(codegenNode);
2903
- if ((!flag || flag === 512 || flag === 1) && getGeneratedPropsConstantType(child, context) >= 2) {
2890
+ const flag = codegenNode.patchFlag;
2891
+ if ((flag === void 0 || flag === 512 || flag === 1) && getGeneratedPropsConstantType(child, context) >= 2) {
2904
2892
  const props = getNodeProps(child);
2905
2893
  if (props) {
2906
2894
  codegenNode.props = context.hoist(props);
@@ -2911,39 +2899,84 @@ function walk(node, context, doNotHoistNode = false) {
2911
2899
  }
2912
2900
  }
2913
2901
  }
2902
+ } else if (child.type === 12) {
2903
+ const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
2904
+ if (constantType >= 2) {
2905
+ toCache.push(child);
2906
+ continue;
2907
+ }
2914
2908
  }
2915
2909
  if (child.type === 1) {
2916
2910
  const isComponent = child.tagType === 1;
2917
2911
  if (isComponent) {
2918
2912
  context.scopes.vSlot++;
2919
2913
  }
2920
- walk(child, context);
2914
+ walk(child, node, context, false, inFor);
2921
2915
  if (isComponent) {
2922
2916
  context.scopes.vSlot--;
2923
2917
  }
2924
2918
  } else if (child.type === 11) {
2925
- walk(child, context, child.children.length === 1);
2919
+ walk(child, node, context, child.children.length === 1, true);
2926
2920
  } else if (child.type === 9) {
2927
2921
  for (let i2 = 0; i2 < child.branches.length; i2++) {
2928
2922
  walk(
2929
2923
  child.branches[i2],
2924
+ node,
2930
2925
  context,
2931
- child.branches[i2].children.length === 1
2926
+ child.branches[i2].children.length === 1,
2927
+ inFor
2932
2928
  );
2933
2929
  }
2934
2930
  }
2935
2931
  }
2936
- if (hoistedCount && context.transformHoist) {
2937
- context.transformHoist(children, context, node);
2932
+ let cachedAsArray = false;
2933
+ if (toCache.length === children.length && node.type === 1) {
2934
+ if (node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && shared.isArray(node.codegenNode.children)) {
2935
+ node.codegenNode.children = getCacheExpression(
2936
+ createArrayExpression(node.codegenNode.children)
2937
+ );
2938
+ cachedAsArray = true;
2939
+ } else if (node.tagType === 1 && node.codegenNode && node.codegenNode.type === 13 && node.codegenNode.children && !shared.isArray(node.codegenNode.children) && node.codegenNode.children.type === 15) {
2940
+ const slot = getSlotNode(node.codegenNode, "default");
2941
+ if (slot) {
2942
+ slot.returns = getCacheExpression(
2943
+ createArrayExpression(slot.returns)
2944
+ );
2945
+ cachedAsArray = true;
2946
+ }
2947
+ } 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) {
2948
+ const slotName = findDir(node, "slot", true);
2949
+ const slot = slotName && slotName.arg && getSlotNode(parent.codegenNode, slotName.arg);
2950
+ if (slot) {
2951
+ slot.returns = getCacheExpression(
2952
+ createArrayExpression(slot.returns)
2953
+ );
2954
+ cachedAsArray = true;
2955
+ }
2956
+ }
2938
2957
  }
2939
- if (hoistedCount && hoistedCount === originalCount && node.type === 1 && node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && shared.isArray(node.codegenNode.children)) {
2940
- const hoisted = context.hoist(
2941
- createArrayExpression(node.codegenNode.children)
2942
- );
2943
- if (context.hmr) {
2944
- hoisted.content = `[...${hoisted.content}]`;
2958
+ if (!cachedAsArray) {
2959
+ for (const child of toCache) {
2960
+ child.codegenNode = context.cache(child.codegenNode);
2961
+ }
2962
+ }
2963
+ function getCacheExpression(value) {
2964
+ const exp = context.cache(value);
2965
+ if (inFor && context.hmr) {
2966
+ exp.needArraySpread = true;
2967
+ }
2968
+ return exp;
2969
+ }
2970
+ function getSlotNode(node2, name) {
2971
+ if (node2.children && !shared.isArray(node2.children) && node2.children.type === 15) {
2972
+ const slot = node2.children.properties.find(
2973
+ (p) => p.key === name || p.key.content === name
2974
+ );
2975
+ return slot && slot.value;
2945
2976
  }
2946
- node.codegenNode.children = hoisted;
2977
+ }
2978
+ if (toCache.length && context.transformHoist) {
2979
+ context.transformHoist(children, context, node);
2947
2980
  }
2948
2981
  }
2949
2982
  function getConstantType(node, context) {
@@ -2961,11 +2994,10 @@ function getConstantType(node, context) {
2961
2994
  if (codegenNode.type !== 13) {
2962
2995
  return 0;
2963
2996
  }
2964
- if (codegenNode.isBlock && node.tag !== "svg" && node.tag !== "foreignObject") {
2997
+ if (codegenNode.isBlock && node.tag !== "svg" && node.tag !== "foreignObject" && node.tag !== "math") {
2965
2998
  return 0;
2966
2999
  }
2967
- const flag = getPatchFlag(codegenNode);
2968
- if (!flag) {
3000
+ if (codegenNode.patchFlag === void 0) {
2969
3001
  let returnType2 = 3;
2970
3002
  const generatedPropsType = getGeneratedPropsConstantType(node, context);
2971
3003
  if (generatedPropsType === 0) {
@@ -3048,6 +3080,8 @@ function getConstantType(node, context) {
3048
3080
  }
3049
3081
  }
3050
3082
  return returnType;
3083
+ case 20:
3084
+ return 2;
3051
3085
  default:
3052
3086
  return 0;
3053
3087
  }
@@ -3107,15 +3141,11 @@ function getNodeProps(node) {
3107
3141
  return codegenNode.props;
3108
3142
  }
3109
3143
  }
3110
- function getPatchFlag(node) {
3111
- const flag = node.patchFlag;
3112
- return flag ? parseInt(flag, 10) : void 0;
3113
- }
3114
3144
 
3115
3145
  function createTransformContext(root, {
3116
3146
  filename = "",
3117
3147
  prefixIdentifiers = false,
3118
- hoistStatic: hoistStatic2 = false,
3148
+ hoistStatic = false,
3119
3149
  hmr = false,
3120
3150
  cacheHandlers = false,
3121
3151
  nodeTransforms = [],
@@ -3142,7 +3172,7 @@ function createTransformContext(root, {
3142
3172
  filename,
3143
3173
  selfName: nameMatch && shared.capitalize(shared.camelize(nameMatch[1])),
3144
3174
  prefixIdentifiers,
3145
- hoistStatic: hoistStatic2,
3175
+ hoistStatic,
3146
3176
  hmr,
3147
3177
  cacheHandlers,
3148
3178
  nodeTransforms,
@@ -3169,9 +3199,9 @@ function createTransformContext(root, {
3169
3199
  directives: /* @__PURE__ */ new Set(),
3170
3200
  hoists: [],
3171
3201
  imports: [],
3202
+ cached: [],
3172
3203
  constantCache: /* @__PURE__ */ new WeakMap(),
3173
3204
  temps: 0,
3174
- cached: 0,
3175
3205
  identifiers: /* @__PURE__ */ Object.create(null),
3176
3206
  scopes: {
3177
3207
  vFor: 0,
@@ -3259,8 +3289,7 @@ function createTransformContext(root, {
3259
3289
  }
3260
3290
  },
3261
3291
  hoist(exp) {
3262
- if (shared.isString(exp))
3263
- exp = createSimpleExpression(exp);
3292
+ if (shared.isString(exp)) exp = createSimpleExpression(exp);
3264
3293
  context.hoists.push(exp);
3265
3294
  const identifier = createSimpleExpression(
3266
3295
  `_hoisted_${context.hoists.length}`,
@@ -3272,7 +3301,13 @@ function createTransformContext(root, {
3272
3301
  return identifier;
3273
3302
  },
3274
3303
  cache(exp, isVNode = false) {
3275
- return createCacheExpression(context.cached++, exp, isVNode);
3304
+ const cacheExp = createCacheExpression(
3305
+ context.cached.length,
3306
+ exp,
3307
+ isVNode
3308
+ );
3309
+ context.cached.push(cacheExp);
3310
+ return cacheExp;
3276
3311
  }
3277
3312
  };
3278
3313
  {
@@ -3294,7 +3329,7 @@ function transform(root, options) {
3294
3329
  const context = createTransformContext(root, options);
3295
3330
  traverseNode(root, context);
3296
3331
  if (options.hoistStatic) {
3297
- hoistStatic(root, context);
3332
+ cacheStatic(root, context);
3298
3333
  }
3299
3334
  if (!options.ssr) {
3300
3335
  createRootCodegen(root, context);
@@ -3337,7 +3372,7 @@ function createRootCodegen(root, context) {
3337
3372
  helper(FRAGMENT),
3338
3373
  void 0,
3339
3374
  root.children,
3340
- patchFlag + (` /* ${patchFlagText} */` ),
3375
+ patchFlag,
3341
3376
  void 0,
3342
3377
  void 0,
3343
3378
  true,
@@ -3353,8 +3388,7 @@ function traverseChildren(parent, context) {
3353
3388
  };
3354
3389
  for (; i < parent.children.length; i++) {
3355
3390
  const child = parent.children[i];
3356
- if (shared.isString(child))
3357
- continue;
3391
+ if (shared.isString(child)) continue;
3358
3392
  context.grandParent = context.parent;
3359
3393
  context.parent = parent;
3360
3394
  context.childIndex = i;
@@ -3425,8 +3459,7 @@ function createStructuralDirectiveTransform(name, fn) {
3425
3459
  props.splice(i, 1);
3426
3460
  i--;
3427
3461
  const onExit = fn(node, prop, context);
3428
- if (onExit)
3429
- exitFns.push(onExit);
3462
+ if (onExit) exitFns.push(onExit);
3430
3463
  }
3431
3464
  }
3432
3465
  return exitFns;
@@ -3525,8 +3558,7 @@ function createCodegenContext(ast, {
3525
3558
  }
3526
3559
  function addMapping(loc, name = null) {
3527
3560
  const { _names, _mappings } = context.map;
3528
- if (name !== null && !_names.has(name))
3529
- _names.add(name);
3561
+ if (name !== null && !_names.has(name)) _names.add(name);
3530
3562
  _mappings.add({
3531
3563
  originalLine: loc.line,
3532
3564
  originalColumn: loc.column - 1,
@@ -3546,8 +3578,7 @@ function createCodegenContext(ast, {
3546
3578
  }
3547
3579
  function generate(ast, options = {}) {
3548
3580
  const context = createCodegenContext(ast, options);
3549
- if (options.onContextCreated)
3550
- options.onContextCreated(context);
3581
+ if (options.onContextCreated) options.onContextCreated(context);
3551
3582
  const {
3552
3583
  mode,
3553
3584
  push,
@@ -3696,10 +3727,6 @@ function genModulePreamble(ast, context, genScopeId, inline) {
3696
3727
  runtimeModuleName,
3697
3728
  ssrRuntimeModuleName
3698
3729
  } = context;
3699
- if (genScopeId && ast.hoists.length) {
3700
- ast.helpers.add(PUSH_SCOPE_ID);
3701
- ast.helpers.add(POP_SCOPE_ID);
3702
- }
3703
3730
  if (ast.helpers.size) {
3704
3731
  const helpers = Array.from(ast.helpers);
3705
3732
  if (optimizeImports) {
@@ -3763,28 +3790,13 @@ function genHoists(hoists, context) {
3763
3790
  return;
3764
3791
  }
3765
3792
  context.pure = true;
3766
- const { push, newline, helper, scopeId, mode } = context;
3767
- const genScopeId = scopeId != null && mode !== "function";
3793
+ const { push, newline } = context;
3768
3794
  newline();
3769
- if (genScopeId) {
3770
- push(
3771
- `const _withScopeId = n => (${helper(
3772
- PUSH_SCOPE_ID
3773
- )}("${scopeId}"),n=n(),${helper(POP_SCOPE_ID)}(),n)`
3774
- );
3775
- newline();
3776
- }
3777
3795
  for (let i = 0; i < hoists.length; i++) {
3778
3796
  const exp = hoists[i];
3779
3797
  if (exp) {
3780
- const needScopeIdWrapper = genScopeId && exp.type === 13;
3781
- push(
3782
- `const _hoisted_${i + 1} = ${needScopeIdWrapper ? `${PURE_ANNOTATION} _withScopeId(() => ` : ``}`
3783
- );
3798
+ push(`const _hoisted_${i + 1} = `);
3784
3799
  genNode(exp, context);
3785
- if (needScopeIdWrapper) {
3786
- push(`)`);
3787
- }
3788
3800
  newline();
3789
3801
  }
3790
3802
  }
@@ -3932,8 +3944,7 @@ function genExpression(node, context) {
3932
3944
  }
3933
3945
  function genInterpolation(node, context) {
3934
3946
  const { push, helper, pure } = context;
3935
- if (pure)
3936
- push(PURE_ANNOTATION);
3947
+ if (pure) push(PURE_ANNOTATION);
3937
3948
  push(`${helper(TO_DISPLAY_STRING)}(`);
3938
3949
  genNode(node.content, context);
3939
3950
  push(`)`);
@@ -3985,6 +3996,17 @@ function genVNodeCall(node, context) {
3985
3996
  disableTracking,
3986
3997
  isComponent
3987
3998
  } = node;
3999
+ let patchFlagString;
4000
+ if (patchFlag) {
4001
+ {
4002
+ if (patchFlag < 0) {
4003
+ patchFlagString = patchFlag + ` /* ${shared.PatchFlagNames[patchFlag]} */`;
4004
+ } else {
4005
+ const flagNames = Object.keys(shared.PatchFlagNames).map(Number).filter((n) => n > 0 && patchFlag & n).map((n) => shared.PatchFlagNames[n]).join(`, `);
4006
+ patchFlagString = patchFlag + ` /* ${flagNames} */`;
4007
+ }
4008
+ }
4009
+ }
3988
4010
  if (directives) {
3989
4011
  push(helper(WITH_DIRECTIVES) + `(`);
3990
4012
  }
@@ -3997,7 +4019,7 @@ function genVNodeCall(node, context) {
3997
4019
  const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent) : getVNodeHelper(context.inSSR, isComponent);
3998
4020
  push(helper(callHelper) + `(`, -2 /* None */, node);
3999
4021
  genNodeList(
4000
- genNullableArgs([tag, props, children, patchFlag, dynamicProps]),
4022
+ genNullableArgs([tag, props, children, patchFlagString, dynamicProps]),
4001
4023
  context
4002
4024
  );
4003
4025
  push(`)`);
@@ -4013,8 +4035,7 @@ function genVNodeCall(node, context) {
4013
4035
  function genNullableArgs(args) {
4014
4036
  let i = args.length;
4015
4037
  while (i--) {
4016
- if (args[i] != null)
4017
- break;
4038
+ if (args[i] != null) break;
4018
4039
  }
4019
4040
  return args.slice(0, i + 1).map((arg) => arg || `null`);
4020
4041
  }
@@ -4131,16 +4152,21 @@ function genConditionalExpression(node, context) {
4131
4152
  }
4132
4153
  function genCacheExpression(node, context) {
4133
4154
  const { push, helper, indent, deindent, newline } = context;
4155
+ const { needPauseTracking, needArraySpread } = node;
4156
+ if (needArraySpread) {
4157
+ push(`[...(`);
4158
+ }
4134
4159
  push(`_cache[${node.index}] || (`);
4135
- if (node.isVNode) {
4160
+ if (needPauseTracking) {
4136
4161
  indent();
4137
4162
  push(`${helper(SET_BLOCK_TRACKING)}(-1),`);
4138
4163
  newline();
4164
+ push(`(`);
4139
4165
  }
4140
4166
  push(`_cache[${node.index}] = `);
4141
4167
  genNode(node.value, context);
4142
- if (node.isVNode) {
4143
- push(`,`);
4168
+ if (needPauseTracking) {
4169
+ push(`).cacheIndex = ${node.index},`);
4144
4170
  newline();
4145
4171
  push(`${helper(SET_BLOCK_TRACKING)}(1),`);
4146
4172
  newline();
@@ -4148,6 +4174,9 @@ function genCacheExpression(node, context) {
4148
4174
  deindent();
4149
4175
  }
4150
4176
  push(`)`);
4177
+ if (needArraySpread) {
4178
+ push(`)]`);
4179
+ }
4151
4180
  }
4152
4181
  function genTemplateLiteral(node, context) {
4153
4182
  const { push, indent, deindent } = context;
@@ -4160,11 +4189,9 @@ function genTemplateLiteral(node, context) {
4160
4189
  push(e.replace(/(`|\$|\\)/g, "\\$1"), -3 /* Unknown */);
4161
4190
  } else {
4162
4191
  push("${");
4163
- if (multilines)
4164
- indent();
4192
+ if (multilines) indent();
4165
4193
  genNode(e, context);
4166
- if (multilines)
4167
- deindent();
4194
+ if (multilines) deindent();
4168
4195
  push("}");
4169
4196
  }
4170
4197
  }
@@ -4213,7 +4240,6 @@ function genReturnStatement({ returns }, context) {
4213
4240
  }
4214
4241
 
4215
4242
  const isLiteralWhitelisted = /* @__PURE__ */ shared.makeMap("true,false,null,this");
4216
- const constantBailRE = /\w\s*\(|\.[^\d]/;
4217
4243
  const transformExpression = (node, context) => {
4218
4244
  if (node.type === 5) {
4219
4245
  node.content = processExpression(
@@ -4308,7 +4334,6 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
4308
4334
  return `_ctx.${raw}`;
4309
4335
  };
4310
4336
  const rawExp = node.content;
4311
- const bailConstant = constantBailRE.test(rawExp);
4312
4337
  let ast = node.ast;
4313
4338
  if (ast === false) {
4314
4339
  return node;
@@ -4370,7 +4395,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
4370
4395
  node2.name = rewriteIdentifier(node2.name, parent, node2);
4371
4396
  ids.push(node2);
4372
4397
  } else {
4373
- if (!(needPrefix && isLocal) && !bailConstant) {
4398
+ if (!(needPrefix && isLocal) && (!parent || parent.type !== "CallExpression" && parent.type !== "NewExpression" && parent.type !== "MemberExpression")) {
4374
4399
  node2.isConstant = true;
4375
4400
  }
4376
4401
  ids.push(node2);
@@ -4414,7 +4439,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
4414
4439
  ret.ast = ast;
4415
4440
  } else {
4416
4441
  ret = node;
4417
- ret.constType = bailConstant ? 0 : 3;
4442
+ ret.constType = 3;
4418
4443
  }
4419
4444
  ret.identifiers = Object.keys(knownIds);
4420
4445
  return ret;
@@ -4540,8 +4565,7 @@ function processIf(node, dir, context, processCodegen) {
4540
4565
  sibling.branches.push(branch);
4541
4566
  const onExit = processCodegen && processCodegen(sibling, branch, false);
4542
4567
  traverseNode(branch, context);
4543
- if (onExit)
4544
- onExit();
4568
+ if (onExit) onExit();
4545
4569
  context.currentNode = null;
4546
4570
  } else {
4547
4571
  context.onError(
@@ -4610,7 +4634,7 @@ function createChildrenCodegenNode(branch, keyIndex, context) {
4610
4634
  helper(FRAGMENT),
4611
4635
  createObjectExpression([keyProperty]),
4612
4636
  children,
4613
- patchFlag + (` /* ${patchFlagText} */` ),
4637
+ patchFlag,
4614
4638
  void 0,
4615
4639
  void 0,
4616
4640
  true,
@@ -4663,6 +4687,90 @@ function getParentCondition(node) {
4663
4687
  }
4664
4688
  }
4665
4689
 
4690
+ const transformBind = (dir, _node, context) => {
4691
+ const { modifiers, loc } = dir;
4692
+ const arg = dir.arg;
4693
+ let { exp } = dir;
4694
+ if (exp && exp.type === 4 && !exp.content.trim()) {
4695
+ {
4696
+ context.onError(
4697
+ createCompilerError(34, loc)
4698
+ );
4699
+ return {
4700
+ props: [
4701
+ createObjectProperty(arg, createSimpleExpression("", true, loc))
4702
+ ]
4703
+ };
4704
+ }
4705
+ }
4706
+ if (!exp) {
4707
+ if (arg.type !== 4 || !arg.isStatic) {
4708
+ context.onError(
4709
+ createCompilerError(
4710
+ 52,
4711
+ arg.loc
4712
+ )
4713
+ );
4714
+ return {
4715
+ props: [
4716
+ createObjectProperty(arg, createSimpleExpression("", true, loc))
4717
+ ]
4718
+ };
4719
+ }
4720
+ transformBindShorthand(dir, context);
4721
+ exp = dir.exp;
4722
+ }
4723
+ if (arg.type !== 4) {
4724
+ arg.children.unshift(`(`);
4725
+ arg.children.push(`) || ""`);
4726
+ } else if (!arg.isStatic) {
4727
+ arg.content = `${arg.content} || ""`;
4728
+ }
4729
+ if (modifiers.includes("camel")) {
4730
+ if (arg.type === 4) {
4731
+ if (arg.isStatic) {
4732
+ arg.content = shared.camelize(arg.content);
4733
+ } else {
4734
+ arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
4735
+ }
4736
+ } else {
4737
+ arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
4738
+ arg.children.push(`)`);
4739
+ }
4740
+ }
4741
+ if (!context.inSSR) {
4742
+ if (modifiers.includes("prop")) {
4743
+ injectPrefix(arg, ".");
4744
+ }
4745
+ if (modifiers.includes("attr")) {
4746
+ injectPrefix(arg, "^");
4747
+ }
4748
+ }
4749
+ return {
4750
+ props: [createObjectProperty(arg, exp)]
4751
+ };
4752
+ };
4753
+ const transformBindShorthand = (dir, context) => {
4754
+ const arg = dir.arg;
4755
+ const propName = shared.camelize(arg.content);
4756
+ dir.exp = createSimpleExpression(propName, false, arg.loc);
4757
+ {
4758
+ dir.exp = processExpression(dir.exp, context);
4759
+ }
4760
+ };
4761
+ const injectPrefix = (arg, prefix) => {
4762
+ if (arg.type === 4) {
4763
+ if (arg.isStatic) {
4764
+ arg.content = prefix + arg.content;
4765
+ } else {
4766
+ arg.content = `\`${prefix}\${${arg.content}}\``;
4767
+ }
4768
+ } else {
4769
+ arg.children.unshift(`'${prefix}' + (`);
4770
+ arg.children.push(`)`);
4771
+ }
4772
+ };
4773
+
4666
4774
  const transformFor = createStructuralDirectiveTransform(
4667
4775
  "for",
4668
4776
  (node, dir, context) => {
@@ -4673,9 +4781,12 @@ const transformFor = createStructuralDirectiveTransform(
4673
4781
  ]);
4674
4782
  const isTemplate = isTemplateNode(node);
4675
4783
  const memo = findDir(node, "memo");
4676
- const keyProp = findProp(node, `key`);
4677
- const keyExp = keyProp && (keyProp.type === 6 ? createSimpleExpression(keyProp.value.content, true) : keyProp.exp);
4678
- const keyProperty = keyProp ? createObjectProperty(`key`, keyExp) : null;
4784
+ const keyProp = findProp(node, `key`, false, true);
4785
+ if (keyProp && keyProp.type === 7 && !keyProp.exp) {
4786
+ transformBindShorthand(keyProp, context);
4787
+ }
4788
+ const keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
4789
+ const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
4679
4790
  if (isTemplate) {
4680
4791
  if (memo) {
4681
4792
  memo.exp = processExpression(
@@ -4697,7 +4808,7 @@ const transformFor = createStructuralDirectiveTransform(
4697
4808
  helper(FRAGMENT),
4698
4809
  void 0,
4699
4810
  renderExp,
4700
- fragmentFlag + (` /* ${shared.PatchFlagNames[fragmentFlag]} */` ),
4811
+ fragmentFlag,
4701
4812
  void 0,
4702
4813
  void 0,
4703
4814
  true,
@@ -4737,7 +4848,7 @@ const transformFor = createStructuralDirectiveTransform(
4737
4848
  helper(FRAGMENT),
4738
4849
  keyProperty ? createObjectExpression([keyProperty]) : void 0,
4739
4850
  node.children,
4740
- 64 + (` /* ${shared.PatchFlagNames[64]} */` ),
4851
+ 64,
4741
4852
  void 0,
4742
4853
  void 0,
4743
4854
  true,
@@ -4791,8 +4902,9 @@ const transformFor = createStructuralDirectiveTransform(
4791
4902
  renderExp.arguments.push(
4792
4903
  loop,
4793
4904
  createSimpleExpression(`_cache`),
4794
- createSimpleExpression(String(context.cached++))
4905
+ createSimpleExpression(String(context.cached.length))
4795
4906
  );
4907
+ context.cached.push(null);
4796
4908
  } else {
4797
4909
  renderExp.arguments.push(
4798
4910
  createFunctionExpression(
@@ -4848,13 +4960,11 @@ function processFor(node, dir, context, processCodegen) {
4848
4960
  key && removeIdentifiers(key);
4849
4961
  index && removeIdentifiers(index);
4850
4962
  }
4851
- if (onExit)
4852
- onExit();
4963
+ if (onExit) onExit();
4853
4964
  };
4854
4965
  }
4855
4966
  function finalizeForParseResult(result, context) {
4856
- if (result.finalized)
4857
- return;
4967
+ if (result.finalized) return;
4858
4968
  if (context.prefixIdentifiers) {
4859
4969
  result.source = processExpression(
4860
4970
  result.source,
@@ -4890,8 +5000,7 @@ function createForLoopParams({ value, key, index }, memoArgs = []) {
4890
5000
  function createParamsList(args) {
4891
5001
  let i = args.length;
4892
5002
  while (i--) {
4893
- if (args[i])
4894
- break;
5003
+ if (args[i]) break;
4895
5004
  }
4896
5005
  return args.slice(0, i + 1).map((arg, i2) => arg || createSimpleExpression(`_`.repeat(i2 + 1), false));
4897
5006
  }
@@ -5023,9 +5132,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
5023
5132
  break;
5024
5133
  }
5025
5134
  }
5026
- if (prev && isTemplateNode(prev) && findDir(prev, "if")) {
5027
- children.splice(i, 1);
5028
- i--;
5135
+ if (prev && isTemplateNode(prev) && findDir(prev, /^(else-)?if$/)) {
5029
5136
  let conditional = dynamicSlots[dynamicSlots.length - 1];
5030
5137
  while (conditional.alternate.type === 19) {
5031
5138
  conditional = conditional.alternate;
@@ -5162,13 +5269,11 @@ function hasForwardedSlots(children) {
5162
5269
  }
5163
5270
  break;
5164
5271
  case 9:
5165
- if (hasForwardedSlots(child.branches))
5166
- return true;
5272
+ if (hasForwardedSlots(child.branches)) return true;
5167
5273
  break;
5168
5274
  case 10:
5169
5275
  case 11:
5170
- if (hasForwardedSlots(child.children))
5171
- return true;
5276
+ if (hasForwardedSlots(child.children)) return true;
5172
5277
  break;
5173
5278
  }
5174
5279
  }
@@ -5193,7 +5298,6 @@ const transformElement = (node, context) => {
5193
5298
  const isDynamicComponent = shared.isObject(vnodeTag) && vnodeTag.callee === RESOLVE_DYNAMIC_COMPONENT;
5194
5299
  let vnodeProps;
5195
5300
  let vnodeChildren;
5196
- let vnodePatchFlag;
5197
5301
  let patchFlag = 0;
5198
5302
  let vnodeDynamicProps;
5199
5303
  let dynamicPropNames;
@@ -5204,7 +5308,7 @@ const transformElement = (node, context) => {
5204
5308
  // updates inside get proper isSVG flag at runtime. (#639, #643)
5205
5309
  // This is technically web-specific, but splitting the logic out of core
5206
5310
  // leads to too much unnecessary complexity.
5207
- (tag === "svg" || tag === "foreignObject")
5311
+ (tag === "svg" || tag === "foreignObject" || tag === "math")
5208
5312
  );
5209
5313
  if (props.length > 0) {
5210
5314
  const propsBuildResult = buildProps(
@@ -5264,25 +5368,15 @@ const transformElement = (node, context) => {
5264
5368
  vnodeChildren = node.children;
5265
5369
  }
5266
5370
  }
5267
- if (patchFlag !== 0) {
5268
- {
5269
- if (patchFlag < 0) {
5270
- vnodePatchFlag = patchFlag + ` /* ${shared.PatchFlagNames[patchFlag]} */`;
5271
- } else {
5272
- const flagNames = Object.keys(shared.PatchFlagNames).map(Number).filter((n) => n > 0 && patchFlag & n).map((n) => shared.PatchFlagNames[n]).join(`, `);
5273
- vnodePatchFlag = patchFlag + ` /* ${flagNames} */`;
5274
- }
5275
- }
5276
- if (dynamicPropNames && dynamicPropNames.length) {
5277
- vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
5278
- }
5371
+ if (dynamicPropNames && dynamicPropNames.length) {
5372
+ vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
5279
5373
  }
5280
5374
  node.codegenNode = createVNodeCall(
5281
5375
  context,
5282
5376
  vnodeTag,
5283
5377
  vnodeProps,
5284
5378
  vnodeChildren,
5285
- vnodePatchFlag,
5379
+ patchFlag === 0 ? void 0 : patchFlag,
5286
5380
  vnodeDynamicProps,
5287
5381
  vnodeDirectives,
5288
5382
  !!shouldUseBlock,
@@ -5330,8 +5424,7 @@ function resolveComponentType(node, context, ssr = false) {
5330
5424
  }
5331
5425
  const builtIn = isCoreComponent(tag) || context.isBuiltInComponent(tag);
5332
5426
  if (builtIn) {
5333
- if (!ssr)
5334
- context.helper(builtIn);
5427
+ if (!ssr) context.helper(builtIn);
5335
5428
  return builtIn;
5336
5429
  }
5337
5430
  {
@@ -5415,8 +5508,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
5415
5508
  );
5416
5509
  properties = [];
5417
5510
  }
5418
- if (arg)
5419
- mergeArgs.push(arg);
5511
+ if (arg) mergeArgs.push(arg);
5420
5512
  };
5421
5513
  const pushRefVForMarker = () => {
5422
5514
  if (context.scopes.vFor > 0) {
@@ -5768,8 +5860,7 @@ function buildDirectiveArgs(dir, context) {
5768
5860
  }
5769
5861
  }
5770
5862
  const { loc } = dir;
5771
- if (dir.exp)
5772
- dirArgs.push(dir.exp);
5863
+ if (dir.exp) dirArgs.push(dir.exp);
5773
5864
  if (dir.arg) {
5774
5865
  if (!dir.exp) {
5775
5866
  dirArgs.push(`void 0`);
@@ -5799,8 +5890,7 @@ function stringifyDynamicPropNames(props) {
5799
5890
  let propsNamesString = `[`;
5800
5891
  for (let i = 0, l = props.length; i < l; i++) {
5801
5892
  propsNamesString += JSON.stringify(props[i]);
5802
- if (i < l - 1)
5803
- propsNamesString += ", ";
5893
+ if (i < l - 1) propsNamesString += ", ";
5804
5894
  }
5805
5895
  return propsNamesString + `]`;
5806
5896
  }
@@ -5897,7 +5987,7 @@ function processSlotOutlet(node, context) {
5897
5987
  };
5898
5988
  }
5899
5989
 
5900
- const fnExpRE = /^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
5990
+ const fnExpRE = /^\s*(async\s*)?(\([^)]*?\)|[\w$_]+)\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
5901
5991
  const transformOn = (dir, node, context, augmentor) => {
5902
5992
  const { loc, modifiers, arg } = dir;
5903
5993
  if (!dir.exp && !modifiers.length) {
@@ -6000,85 +6090,6 @@ const transformOn = (dir, node, context, augmentor) => {
6000
6090
  return ret;
6001
6091
  };
6002
6092
 
6003
- const transformBind = (dir, _node, context) => {
6004
- const { modifiers, loc } = dir;
6005
- const arg = dir.arg;
6006
- let { exp } = dir;
6007
- if (exp && exp.type === 4 && !exp.content.trim()) {
6008
- {
6009
- context.onError(
6010
- createCompilerError(34, loc)
6011
- );
6012
- return {
6013
- props: [
6014
- createObjectProperty(arg, createSimpleExpression("", true, loc))
6015
- ]
6016
- };
6017
- }
6018
- }
6019
- if (!exp) {
6020
- if (arg.type !== 4 || !arg.isStatic) {
6021
- context.onError(
6022
- createCompilerError(
6023
- 52,
6024
- arg.loc
6025
- )
6026
- );
6027
- return {
6028
- props: [
6029
- createObjectProperty(arg, createSimpleExpression("", true, loc))
6030
- ]
6031
- };
6032
- }
6033
- const propName = shared.camelize(arg.content);
6034
- exp = dir.exp = createSimpleExpression(propName, false, arg.loc);
6035
- {
6036
- exp = dir.exp = processExpression(exp, context);
6037
- }
6038
- }
6039
- if (arg.type !== 4) {
6040
- arg.children.unshift(`(`);
6041
- arg.children.push(`) || ""`);
6042
- } else if (!arg.isStatic) {
6043
- arg.content = `${arg.content} || ""`;
6044
- }
6045
- if (modifiers.includes("camel")) {
6046
- if (arg.type === 4) {
6047
- if (arg.isStatic) {
6048
- arg.content = shared.camelize(arg.content);
6049
- } else {
6050
- arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
6051
- }
6052
- } else {
6053
- arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
6054
- arg.children.push(`)`);
6055
- }
6056
- }
6057
- if (!context.inSSR) {
6058
- if (modifiers.includes("prop")) {
6059
- injectPrefix(arg, ".");
6060
- }
6061
- if (modifiers.includes("attr")) {
6062
- injectPrefix(arg, "^");
6063
- }
6064
- }
6065
- return {
6066
- props: [createObjectProperty(arg, exp)]
6067
- };
6068
- };
6069
- const injectPrefix = (arg, prefix) => {
6070
- if (arg.type === 4) {
6071
- if (arg.isStatic) {
6072
- arg.content = prefix + arg.content;
6073
- } else {
6074
- arg.content = `\`${prefix}\${${arg.content}}\``;
6075
- }
6076
- } else {
6077
- arg.children.unshift(`'${prefix}' + (`);
6078
- arg.children.push(`)`);
6079
- }
6080
- };
6081
-
6082
6093
  const transformText = (node, context) => {
6083
6094
  if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
6084
6095
  return () => {
@@ -6266,8 +6277,7 @@ const transformFilter = (node, context) => {
6266
6277
  }
6267
6278
  if (node.type === 5) {
6268
6279
  rewriteFilter(node.content, context);
6269
- }
6270
- if (node.type === 1) {
6280
+ } else if (node.type === 1) {
6271
6281
  node.props.forEach((prop) => {
6272
6282
  if (prop.type === 7 && prop.name !== "for" && prop.exp) {
6273
6283
  rewriteFilter(prop.exp, context);
@@ -6281,8 +6291,7 @@ function rewriteFilter(node, context) {
6281
6291
  } else {
6282
6292
  for (let i = 0; i < node.children.length; i++) {
6283
6293
  const child = node.children[i];
6284
- if (typeof child !== "object")
6285
- continue;
6294
+ if (typeof child !== "object") continue;
6286
6295
  if (child.type === 4) {
6287
6296
  parseFilter(child, context);
6288
6297
  } else if (child.type === 8) {
@@ -6308,17 +6317,13 @@ function parseFilter(node, context) {
6308
6317
  prev = c;
6309
6318
  c = exp.charCodeAt(i);
6310
6319
  if (inSingle) {
6311
- if (c === 39 && prev !== 92)
6312
- inSingle = false;
6320
+ if (c === 39 && prev !== 92) inSingle = false;
6313
6321
  } else if (inDouble) {
6314
- if (c === 34 && prev !== 92)
6315
- inDouble = false;
6322
+ if (c === 34 && prev !== 92) inDouble = false;
6316
6323
  } else if (inTemplateString) {
6317
- if (c === 96 && prev !== 92)
6318
- inTemplateString = false;
6324
+ if (c === 96 && prev !== 92) inTemplateString = false;
6319
6325
  } else if (inRegex) {
6320
- if (c === 47 && prev !== 92)
6321
- inRegex = false;
6326
+ if (c === 47 && prev !== 92) inRegex = false;
6322
6327
  } else if (c === 124 && // pipe
6323
6328
  exp.charCodeAt(i + 1) !== 124 && exp.charCodeAt(i - 1) !== 124 && !curly && !square && !paren) {
6324
6329
  if (expression === void 0) {
@@ -6362,8 +6367,7 @@ function parseFilter(node, context) {
6362
6367
  let p;
6363
6368
  for (; j >= 0; j--) {
6364
6369
  p = exp.charAt(j);
6365
- if (p !== " ")
6366
- break;
6370
+ if (p !== " ") break;
6367
6371
  }
6368
6372
  if (!p || !validDivisionCharRE.test(p)) {
6369
6373
  inRegex = true;
@@ -6390,6 +6394,7 @@ function parseFilter(node, context) {
6390
6394
  expression = wrapFilter(expression, filters[i], context);
6391
6395
  }
6392
6396
  node.content = expression;
6397
+ node.ast = void 0;
6393
6398
  }
6394
6399
  }
6395
6400
  function wrapFilter(exp, filter, context) {
@@ -6424,8 +6429,9 @@ const transformMemo = (node, context) => {
6424
6429
  dir.exp,
6425
6430
  createFunctionExpression(void 0, codegenNode),
6426
6431
  `_cache`,
6427
- String(context.cached++)
6432
+ String(context.cached.length)
6428
6433
  ]);
6434
+ context.cached.push(null);
6429
6435
  }
6430
6436
  };
6431
6437
  }