@vue/compiler-dom 3.6.0-beta.9 → 3.6.0-rc.10

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-beta.9
2
+ * @vue/compiler-dom v3.6.0-rc.10
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -11,7 +11,7 @@
11
11
  * \/\*#\_\_PURE\_\_\*\/
12
12
  * So that they can be tree-shaken if necessary.
13
13
  */
14
- /* @__NO_SIDE_EFFECTS__ */
14
+ /*@__NO_SIDE_EFFECTS__*/
15
15
  function makeMap(str) {
16
16
  const map = Object.create(null);
17
17
  for (const key of str.split(",")) map[key] = 1;
@@ -32,8 +32,8 @@ const isArray = Array.isArray;
32
32
  const isString = (val) => typeof val === "string";
33
33
  const isSymbol = (val) => typeof val === "symbol";
34
34
  const isObject = (val) => val !== null && typeof val === "object";
35
- const isReservedProp = /* @__PURE__ */ makeMap(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted");
36
- const isBuiltInDirective = /* @__PURE__ */ makeMap("bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo");
35
+ const isReservedProp = /*@__PURE__*/ makeMap(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted");
36
+ const isBuiltInDirective = /*@__PURE__*/ makeMap("bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo");
37
37
  const cacheStringFunction = (fn) => {
38
38
  const cache = Object.create(null);
39
39
  return ((str) => {
@@ -46,8 +46,6 @@ const camelizeReplacer = (_, c) => c ? c.toUpperCase() : "";
46
46
  * @private
47
47
  */
48
48
  const camelize = cacheStringFunction((str) => str.replace(camelizeRE, camelizeReplacer));
49
- const hyphenateRE = /\B([A-Z])/g;
50
- cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
51
49
  /**
52
50
  * @private
53
51
  */
@@ -142,10 +140,10 @@ function generateCodeFrame(source, start = 0, end = source.length) {
142
140
  //#region packages/shared/src/normalizeProp.ts
143
141
  const listDelimiterRE = /;(?![^(]*\))/g;
144
142
  const propertyDelimiterRE = /:([^]+)/;
145
- const styleCommentRE = /\/\*[^]*?\*\//g;
143
+ const styleCommentRE = /"(?:[^"\\]|\\[^])*"|'(?:[^'\\]|\\[^])*'|\\[^]|\/\*[^]*?\*\//g;
146
144
  function parseStringStyle(cssText) {
147
145
  const ret = {};
148
- cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
146
+ cssText.replace(styleCommentRE, (match) => match.startsWith("/*") ? "" : match).split(listDelimiterRE).forEach((item) => {
149
147
  if (item) {
150
148
  const tmp = item.split(propertyDelimiterRE);
151
149
  tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
@@ -163,22 +161,22 @@ const VOID_TAGS = "area,base,br,col,embed,hr,img,input,link,meta,param,source,tr
163
161
  * Compiler only.
164
162
  * Do NOT use in runtime code paths unless behind `__DEV__` flag.
165
163
  */
166
- const isHTMLTag = /* @__PURE__ */ makeMap(HTML_TAGS);
164
+ const isHTMLTag = /*@__PURE__*/ makeMap(HTML_TAGS);
167
165
  /**
168
166
  * Compiler only.
169
167
  * Do NOT use in runtime code paths unless behind `__DEV__` flag.
170
168
  */
171
- const isSVGTag = /* @__PURE__ */ makeMap(SVG_TAGS);
169
+ const isSVGTag = /*@__PURE__*/ makeMap(SVG_TAGS);
172
170
  /**
173
171
  * Compiler only.
174
172
  * Do NOT use in runtime code paths unless behind `__DEV__` flag.
175
173
  */
176
- const isMathMLTag = /* @__PURE__ */ makeMap(MATH_TAGS);
174
+ const isMathMLTag = /*@__PURE__*/ makeMap(MATH_TAGS);
177
175
  /**
178
176
  * Compiler only.
179
177
  * Do NOT use in runtime code paths unless behind `__DEV__` flag.
180
178
  */
181
- const isVoidTag = /* @__PURE__ */ makeMap(VOID_TAGS);
179
+ const isVoidTag = /*@__PURE__*/ makeMap(VOID_TAGS);
182
180
  //#endregion
183
181
  //#region packages/compiler-core/src/runtimeHelpers.ts
184
182
  const FRAGMENT = Symbol(`Fragment`);
@@ -723,13 +721,14 @@ var Tokenizer = class {
723
721
  }
724
722
  }
725
723
  stateInterpolationOpen(c) {
726
- if (c === this.delimiterOpen[this.delimiterIndex]) if (this.delimiterIndex === this.delimiterOpen.length - 1) {
727
- const start = this.index + 1 - this.delimiterOpen.length;
728
- if (start > this.sectionStart) this.cbs.ontext(this.sectionStart, start);
729
- this.state = 3;
730
- this.sectionStart = start;
731
- } else this.delimiterIndex++;
732
- else if (this.inRCDATA) {
724
+ if (c === this.delimiterOpen[this.delimiterIndex]) {
725
+ if (this.delimiterIndex === this.delimiterOpen.length - 1) {
726
+ const start = this.index + 1 - this.delimiterOpen.length;
727
+ if (start > this.sectionStart) this.cbs.ontext(this.sectionStart, start);
728
+ this.state = 3;
729
+ this.sectionStart = start;
730
+ } else this.delimiterIndex++;
731
+ } else if (this.inRCDATA) {
733
732
  this.state = 32;
734
733
  this.stateInRCDATA(c);
735
734
  } else {
@@ -745,13 +744,14 @@ var Tokenizer = class {
745
744
  }
746
745
  }
747
746
  stateInterpolationClose(c) {
748
- if (c === this.delimiterClose[this.delimiterIndex]) if (this.delimiterIndex === this.delimiterClose.length - 1) {
749
- this.cbs.oninterpolation(this.sectionStart, this.index + 1);
750
- if (this.inRCDATA) this.state = 32;
751
- else this.state = 1;
752
- this.sectionStart = this.index + 1;
753
- } else this.delimiterIndex++;
754
- else {
747
+ if (c === this.delimiterClose[this.delimiterIndex]) {
748
+ if (this.delimiterIndex === this.delimiterClose.length - 1) {
749
+ this.cbs.oninterpolation(this.sectionStart, this.index + 1);
750
+ if (this.inRCDATA) this.state = 32;
751
+ else this.state = 1;
752
+ this.sectionStart = this.index + 1;
753
+ } else this.delimiterIndex++;
754
+ } else {
755
755
  this.state = 3;
756
756
  this.stateInterpolation(c);
757
757
  }
@@ -866,9 +866,10 @@ var Tokenizer = class {
866
866
  this.sectionStart = this.index;
867
867
  if (this.mode === 0) this.state = 6;
868
868
  else if (this.inSFCRoot) this.state = 34;
869
- else if (!this.inXML) if (c === 116) this.state = 30;
870
- else this.state = c === 115 ? 29 : 6;
871
- else this.state = 6;
869
+ else if (!this.inXML) {
870
+ if (c === 116) this.state = 30;
871
+ else this.state = c === 115 ? 29 : 6;
872
+ } else this.state = 6;
872
873
  } else if (c === 47) this.state = 8;
873
874
  else {
874
875
  this.state = 1;
@@ -1221,9 +1222,7 @@ var Tokenizer = class {
1221
1222
  case 24:
1222
1223
  this.stateInProcessingInstruction(c);
1223
1224
  break;
1224
- case 33:
1225
- this.stateInEntity();
1226
- break;
1225
+ case 33: this.stateInEntity();
1227
1226
  }
1228
1227
  this.index++;
1229
1228
  }
@@ -1252,9 +1251,10 @@ var Tokenizer = class {
1252
1251
  handleTrailingData() {
1253
1252
  const endIndex = this.buffer.length;
1254
1253
  if (this.sectionStart >= endIndex) return;
1255
- if (this.state === 28) if (this.currentSequence === Sequences.CdataEnd) this.cbs.oncdata(this.sectionStart, endIndex);
1256
- else this.cbs.oncomment(this.sectionStart, endIndex);
1257
- else if (this.state === 6 || this.state === 11 || this.state === 18 || this.state === 17 || this.state === 12 || this.state === 13 || this.state === 14 || this.state === 15 || this.state === 16 || this.state === 20 || this.state === 19 || this.state === 21 || this.state === 9) {} else this.cbs.ontext(this.sectionStart, endIndex);
1254
+ if (this.state === 28) {
1255
+ if (this.currentSequence === Sequences.CdataEnd) this.cbs.oncdata(this.sectionStart, endIndex);
1256
+ else this.cbs.oncomment(this.sectionStart, endIndex);
1257
+ } else if (this.state === 6 || this.state === 11 || this.state === 18 || this.state === 17 || this.state === 12 || this.state === 13 || this.state === 14 || this.state === 15 || this.state === 16 || this.state === 20 || this.state === 19 || this.state === 21 || this.state === 9) {} else this.cbs.ontext(this.sectionStart, endIndex);
1258
1258
  }
1259
1259
  emitCodePoint(cp, consumed) {}
1260
1260
  };
@@ -1587,9 +1587,7 @@ function extractIdentifiers(param, nodes = []) {
1587
1587
  case "RestElement":
1588
1588
  extractIdentifiers(param.argument, nodes);
1589
1589
  break;
1590
- case "AssignmentPattern":
1591
- extractIdentifiers(param.left, nodes);
1592
- break;
1590
+ case "AssignmentPattern": extractIdentifiers(param.left, nodes);
1593
1591
  }
1594
1592
  return nodes;
1595
1593
  }
@@ -1725,12 +1723,10 @@ const isMemberExpressionBrowser = (exp) => {
1725
1723
  if (!--currentOpenParensCount) state = stateStack.pop();
1726
1724
  }
1727
1725
  break;
1728
- case 3:
1729
- if (char === currentStringType) {
1730
- state = stateStack.pop();
1731
- currentStringType = null;
1732
- }
1733
- break;
1726
+ case 3: if (char === currentStringType) {
1727
+ state = stateStack.pop();
1728
+ currentStringType = null;
1729
+ }
1734
1730
  }
1735
1731
  }
1736
1732
  return !currentOpenBracketCount && !currentOpenParensCount;
@@ -1801,7 +1797,7 @@ function isTemplateNode(node) {
1801
1797
  function isSlotOutlet(node) {
1802
1798
  return node.type === 1 && node.tagType === 2;
1803
1799
  }
1804
- const propsHelperSet = new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
1800
+ const propsHelperSet = /* @__PURE__ */ new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
1805
1801
  function getUnnormalizedProps(props, callPath = []) {
1806
1802
  if (props && !isString(props) && props.type === 14) {
1807
1803
  const callee = props.callee;
@@ -1810,6 +1806,7 @@ function getUnnormalizedProps(props, callPath = []) {
1810
1806
  return [props, callPath];
1811
1807
  }
1812
1808
  function injectProp(node, prop, context) {
1809
+ if (node.type !== 13 && injectSlotKey(node, prop)) return;
1813
1810
  let propsWithInjection;
1814
1811
  /**
1815
1812
  * 1. mergeProps(...)
@@ -1843,11 +1840,26 @@ function injectProp(node, prop, context) {
1843
1840
  propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [createObjectExpression([prop]), props]);
1844
1841
  if (parentCall && parentCall.callee === GUARD_REACTIVE_PROPS) parentCall = callPath[callPath.length - 2];
1845
1842
  }
1846
- if (node.type === 13) if (parentCall) parentCall.arguments[0] = propsWithInjection;
1847
- else node.props = propsWithInjection;
1848
- else if (parentCall) parentCall.arguments[0] = propsWithInjection;
1843
+ if (node.type === 13) {
1844
+ if (parentCall) parentCall.arguments[0] = propsWithInjection;
1845
+ else node.props = propsWithInjection;
1846
+ } else if (parentCall) parentCall.arguments[0] = propsWithInjection;
1849
1847
  else node.arguments[2] = propsWithInjection;
1850
1848
  }
1849
+ function injectSlotKey(node, prop) {
1850
+ var _node$arguments, _node$arguments2, _node$arguments3;
1851
+ if (prop.key.type !== 4 || prop.key.content !== "key") return false;
1852
+ const props = node.arguments[2];
1853
+ if (props && !isString(props)) {
1854
+ const [unnormalizedProps] = getUnnormalizedProps(props);
1855
+ if (unnormalizedProps && !isString(unnormalizedProps) && unnormalizedProps.type === 15 && hasProp(prop, unnormalizedProps)) return true;
1856
+ }
1857
+ (_node$arguments = node.arguments)[2] || (_node$arguments[2] = "{}");
1858
+ (_node$arguments2 = node.arguments)[3] || (_node$arguments2[3] = "undefined");
1859
+ (_node$arguments3 = node.arguments)[4] || (_node$arguments3[4] = "undefined");
1860
+ node.arguments[5] = prop.value;
1861
+ return true;
1862
+ }
1851
1863
  function hasProp(prop, props) {
1852
1864
  let result = false;
1853
1865
  if (prop.key.type === 4) {
@@ -2146,10 +2158,7 @@ const tokenizer = new Tokenizer(stack, {
2146
2158
  case 18:
2147
2159
  case 19:
2148
2160
  case 20:
2149
- case 21:
2150
- emitError(9, end);
2151
- break;
2152
- default: break;
2161
+ case 21: emitError(9, end);
2153
2162
  }
2154
2163
  for (let index = 0; index < stack.length; index++) {
2155
2164
  onCloseTag(stack[index], end - 1);
@@ -2157,7 +2166,7 @@ const tokenizer = new Tokenizer(stack, {
2157
2166
  }
2158
2167
  },
2159
2168
  oncdata(start, end) {
2160
- if (stack[0].ns !== 0) onText(getSlice(start, end), start, end);
2169
+ if ((stack[0] ? stack[0].ns : currentOptions.ns) !== 0) onText(getSlice(start, end), start, end);
2161
2170
  else emitError(1, start - 9);
2162
2171
  },
2163
2172
  onprocessinginstruction(start) {
@@ -2299,7 +2308,7 @@ function backTrack(index, c) {
2299
2308
  while (currentInput.charCodeAt(i) !== c && i >= 0) i--;
2300
2309
  return i;
2301
2310
  }
2302
- const specialTemplateDir = new Set([
2311
+ const specialTemplateDir = /* @__PURE__ */ new Set([
2303
2312
  "if",
2304
2313
  "else",
2305
2314
  "else-if",
@@ -2335,16 +2344,18 @@ function condenseWhitespace(nodes) {
2335
2344
  let removedWhitespace = false;
2336
2345
  for (let i = 0; i < nodes.length; i++) {
2337
2346
  const node = nodes[i];
2338
- if (node.type === 2) if (!inPre) {
2339
- if (isAllWhitespace(node.content)) {
2340
- const prev = nodes[i - 1] && nodes[i - 1].type;
2341
- const next = nodes[i + 1] && nodes[i + 1].type;
2342
- if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
2343
- removedWhitespace = true;
2344
- nodes[i] = null;
2345
- } else node.content = " ";
2346
- } else if (shouldCondense) node.content = condense(node.content);
2347
- } else node.content = node.content.replace(windowsNewlineRE, "\n");
2347
+ if (node.type === 2) {
2348
+ if (!inPre) {
2349
+ if (isAllWhitespace(node.content)) {
2350
+ const prev = nodes[i - 1] && nodes[i - 1].type;
2351
+ const next = nodes[i + 1] && nodes[i + 1].type;
2352
+ if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
2353
+ removedWhitespace = true;
2354
+ nodes[i] = null;
2355
+ } else node.content = " ";
2356
+ } else if (shouldCondense) node.content = condense(node.content);
2357
+ } else node.content = node.content.replace(windowsNewlineRE, "\n");
2358
+ }
2348
2359
  }
2349
2360
  return removedWhitespace ? nodes.filter(Boolean) : nodes;
2350
2361
  }
@@ -2605,7 +2616,7 @@ function getConstantType(node, context) {
2605
2616
  default: return 0;
2606
2617
  }
2607
2618
  }
2608
- const allowHoistedHelperSet = new Set([
2619
+ const allowHoistedHelperSet = /* @__PURE__ */ new Set([
2609
2620
  NORMALIZE_CLASS,
2610
2621
  NORMALIZE_STYLE,
2611
2622
  NORMALIZE_PROPS,
@@ -2682,8 +2693,10 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
2682
2693
  imports: [],
2683
2694
  cached: [],
2684
2695
  constantCache: /* @__PURE__ */ new WeakMap(),
2696
+ vForMemoKeyedNodes: /* @__PURE__ */ new WeakSet(),
2685
2697
  temps: 0,
2686
2698
  identifiers: Object.create(null),
2699
+ identifierScopes: Object.create(null),
2687
2700
  scopes: {
2688
2701
  vFor: 0,
2689
2702
  vSlot: 0,
@@ -2734,8 +2747,12 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
2734
2747
  context.parent.children.splice(removalIndex, 1);
2735
2748
  },
2736
2749
  onNodeRemoved: NOOP,
2737
- addIdentifiers(exp) {},
2750
+ addIdentifiers(exp, type = "local") {},
2738
2751
  removeIdentifiers(exp) {},
2752
+ isSlotScopeIdentifier(name) {
2753
+ const scopes = context.identifierScopes[name];
2754
+ return scopes ? scopes[scopes.length - 1] === "slot" : false;
2755
+ },
2739
2756
  hoist(exp) {
2740
2757
  if (isString(exp)) exp = createSimpleExpression(exp);
2741
2758
  context.hoists.push(exp);
@@ -2757,7 +2774,7 @@ function transform(root, options) {
2757
2774
  traverseNode(root, context);
2758
2775
  if (options.hoistStatic) cacheStatic(root, context);
2759
2776
  if (!options.ssr) createRootCodegen(root, context);
2760
- root.helpers = new Set([...context.helpers.keys()]);
2777
+ root.helpers = /* @__PURE__ */ new Set([...context.helpers.keys()]);
2761
2778
  root.components = [...context.components];
2762
2779
  root.directives = [...context.directives];
2763
2780
  root.imports = context.imports;
@@ -2804,8 +2821,10 @@ function traverseNode(node, context) {
2804
2821
  const exitFns = [];
2805
2822
  for (let i = 0; i < nodeTransforms.length; i++) {
2806
2823
  const onExit = nodeTransforms[i](node, context);
2807
- if (onExit) if (isArray(onExit)) exitFns.push(...onExit);
2808
- else exitFns.push(onExit);
2824
+ if (onExit) {
2825
+ if (isArray(onExit)) exitFns.push(...onExit);
2826
+ else exitFns.push(onExit);
2827
+ }
2809
2828
  if (!context.currentNode) return;
2810
2829
  else node = context.currentNode;
2811
2830
  }
@@ -2822,9 +2841,7 @@ function traverseNode(node, context) {
2822
2841
  case 10:
2823
2842
  case 11:
2824
2843
  case 1:
2825
- case 0:
2826
- traverseChildren(node, context);
2827
- break;
2844
+ case 0: traverseChildren(node, context);
2828
2845
  }
2829
2846
  context.currentNode = node;
2830
2847
  let i = exitFns.length;
@@ -3030,10 +3047,12 @@ function genNodeList(nodes, context, multilines = false, comma = true) {
3030
3047
  if (isString(node)) push(node, -3);
3031
3048
  else if (isArray(node)) genNodeListAsArray(node, context);
3032
3049
  else genNode(node, context);
3033
- if (i < nodes.length - 1) if (multilines) {
3034
- comma && push(",");
3035
- newline();
3036
- } else comma && push(", ");
3050
+ if (i < nodes.length - 1) {
3051
+ if (multilines) {
3052
+ comma && push(",");
3053
+ newline();
3054
+ } else comma && push(", ");
3055
+ }
3037
3056
  }
3038
3057
  }
3039
3058
  function genNode(node, context) {
@@ -3099,6 +3118,7 @@ function genNode(node, context) {
3099
3118
  case 24: break;
3100
3119
  case 25: break;
3101
3120
  case 26: break;
3121
+ /* v8 ignore start */
3102
3122
  case 10: break;
3103
3123
  default:
3104
3124
  assert(false, `unhandled codegen node type: ${node.type}`);
@@ -3144,8 +3164,10 @@ function genVNodeCall(node, context) {
3144
3164
  const { push, helper, pure } = context;
3145
3165
  const { tag, props, children, patchFlag, dynamicProps, directives, isBlock, disableTracking, isComponent } = node;
3146
3166
  let patchFlagString;
3147
- if (patchFlag) if (patchFlag < 0) patchFlagString = patchFlag + ` /* ${PatchFlagNames[patchFlag]} */`;
3148
- else patchFlagString = patchFlag + ` /* ${Object.keys(PatchFlagNames).map(Number).filter((n) => n > 0 && patchFlag & n).map((n) => PatchFlagNames[n]).join(`, `)} */`;
3167
+ if (patchFlag) {
3168
+ if (patchFlag < 0) patchFlagString = patchFlag + ` /* ${PatchFlagNames[patchFlag]} */`;
3169
+ else patchFlagString = patchFlag + ` /* ${Object.keys(PatchFlagNames).map(Number).filter((n) => n > 0 && patchFlag & n).map((n) => PatchFlagNames[n]).join(`, `)} */`;
3170
+ }
3149
3171
  if (directives) push(helper(WITH_DIRECTIVES) + `(`);
3150
3172
  if (isBlock) push(`(${helper(OPEN_BLOCK)}(${disableTracking ? `true` : ``}), `);
3151
3173
  if (pure) push(PURE_ANNOTATION);
@@ -3307,7 +3329,7 @@ function validateBrowserExpression(node, context, asParams = false, asRawStateme
3307
3329
  }
3308
3330
  //#endregion
3309
3331
  //#region packages/compiler-core/src/transforms/transformExpression.ts
3310
- const isLiteralWhitelisted = /* @__PURE__ */ makeMap("true,false,null,this");
3332
+ const isLiteralWhitelisted = /*@__PURE__*/ makeMap("true,false,null,this");
3311
3333
  const transformExpression = (node, context) => {
3312
3334
  if (node.type === 5) node.content = processExpression(node.content, context);
3313
3335
  else if (node.type === 1) {
@@ -3317,7 +3339,7 @@ const transformExpression = (node, context) => {
3317
3339
  if (dir.type === 7 && dir.name !== "for") {
3318
3340
  const exp = dir.exp;
3319
3341
  const arg = dir.arg;
3320
- if (exp && exp.type === 4 && !(dir.name === "on" && arg) && !(memo && arg && arg.type === 4 && arg.content === "key")) dir.exp = processExpression(exp, context, dir.name === "slot");
3342
+ if (exp && exp.type === 4 && !(dir.name === "on" && arg) && !(memo && context.vForMemoKeyedNodes.has(node) && arg && arg.type === 4 && arg.content === "key")) dir.exp = processExpression(exp, context, dir.name === "slot");
3321
3343
  if (arg && arg.type === 4 && !arg.isStatic) dir.arg = processExpression(arg, context);
3322
3344
  }
3323
3345
  }
@@ -3420,16 +3442,17 @@ function createChildrenCodegenNode(branch, keyIndex, context) {
3420
3442
  const keyProperty = createObjectProperty(`key`, createSimpleExpression(`${keyIndex}`, false, locStub, 2));
3421
3443
  const { children } = branch;
3422
3444
  const firstChild = children[0];
3423
- if (children.length !== 1 || firstChild.type !== 1) if (children.length === 1 && firstChild.type === 11) {
3424
- const vnodeCall = firstChild.codegenNode;
3425
- injectProp(vnodeCall, keyProperty, context);
3426
- return vnodeCall;
3445
+ if (children.length !== 1 || firstChild.type !== 1) {
3446
+ if (children.length === 1 && firstChild.type === 11) {
3447
+ const vnodeCall = firstChild.codegenNode;
3448
+ injectProp(vnodeCall, keyProperty, context);
3449
+ return vnodeCall;
3450
+ } else {
3451
+ let patchFlag = 64;
3452
+ if (!branch.isTemplateIf && children.filter((c) => c.type !== 3).length === 1) patchFlag |= 2048;
3453
+ return createVNodeCall(context, helper(FRAGMENT), createObjectExpression([keyProperty]), children, patchFlag, void 0, void 0, true, false, false, branch.loc);
3454
+ }
3427
3455
  } else {
3428
- let patchFlag = 64;
3429
- if (!branch.isTemplateIf && children.filter((c) => c.type !== 3).length === 1) patchFlag |= 2048;
3430
- return createVNodeCall(context, helper(FRAGMENT), createObjectExpression([keyProperty]), children, patchFlag, void 0, void 0, true, false, false, branch.loc);
3431
- }
3432
- else {
3433
3456
  const ret = firstChild.codegenNode;
3434
3457
  const vnodeCall = getMemoedVNodeCall(ret);
3435
3458
  if (vnodeCall.type === 13) convertToBlock(vnodeCall, context);
@@ -3450,9 +3473,10 @@ function isSameKey(a, b) {
3450
3473
  return true;
3451
3474
  }
3452
3475
  function getParentCondition(node) {
3453
- while (true) if (node.type === 19) if (node.alternate.type === 19) node = node.alternate;
3454
- else return node;
3455
- else if (node.type === 20) node = node.value;
3476
+ while (true) if (node.type === 19) {
3477
+ if (node.alternate.type === 19) node = node.alternate;
3478
+ else return node;
3479
+ } else if (node.type === 20) node = node.value;
3456
3480
  }
3457
3481
  //#endregion
3458
3482
  //#region packages/compiler-core/src/transforms/vFor.ts
@@ -3463,10 +3487,9 @@ const transformFor = createStructuralDirectiveTransform("for", (node, dir, conte
3463
3487
  const isTemplate = isTemplateNode(node);
3464
3488
  const memo = findDir(node, "memo");
3465
3489
  const keyProp = findProp(node, `key`, false, true);
3466
- const isDirKey = keyProp && keyProp.type === 7;
3490
+ keyProp && keyProp.type;
3467
3491
  let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
3468
- if (memo && keyExp && isDirKey) {}
3469
- const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
3492
+ const keyProperty = keyExp ? createObjectProperty(`key`, keyExp) : null;
3470
3493
  const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
3471
3494
  const fragmentFlag = isStableFragment ? 64 : keyProp ? 128 : 256;
3472
3495
  forNode.codegenNode = createVNodeCall(context, helper(FRAGMENT), void 0, renderExp, fragmentFlag, void 0, void 0, true, !isStableFragment, false, node.loc);
@@ -3491,15 +3514,24 @@ const transformFor = createStructuralDirectiveTransform("for", (node, dir, conte
3491
3514
  else {
3492
3515
  childBlock = children[0].codegenNode;
3493
3516
  if (isTemplate && keyProperty) injectProp(childBlock, keyProperty, context);
3494
- if (childBlock.isBlock !== !isStableFragment) if (childBlock.isBlock) {
3495
- removeHelper(OPEN_BLOCK);
3496
- removeHelper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
3497
- } else removeHelper(getVNodeHelper(context.inSSR, childBlock.isComponent));
3498
- childBlock.isBlock = !isStableFragment;
3517
+ const shouldUseBlock = !isStableFragment || childBlock.isBlockRequired === true;
3518
+ if (childBlock.isBlock !== shouldUseBlock) {
3519
+ if (childBlock.isBlock) {
3520
+ removeHelper(OPEN_BLOCK);
3521
+ removeHelper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
3522
+ } else removeHelper(getVNodeHelper(context.inSSR, childBlock.isComponent));
3523
+ }
3524
+ childBlock.isBlock = shouldUseBlock;
3499
3525
  if (childBlock.isBlock) {
3500
3526
  helper(OPEN_BLOCK);
3501
3527
  helper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
3502
- } else helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
3528
+ } else {
3529
+ helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
3530
+ if (childBlock.needsPatch) {
3531
+ var _childBlock$patchFlag;
3532
+ childBlock.patchFlag = ((_childBlock$patchFlag = childBlock.patchFlag) !== null && _childBlock$patchFlag !== void 0 ? _childBlock$patchFlag : 0) | 512;
3533
+ }
3534
+ }
3503
3535
  }
3504
3536
  if (memo) {
3505
3537
  const loop = createFunctionExpression(createForLoopParams(forNode.parseResult, [createSimpleExpression(`_cached`)]));
@@ -3690,8 +3722,10 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
3690
3722
  return createObjectProperty(`default`, fn);
3691
3723
  };
3692
3724
  if (!hasTemplateSlots) slotsProperties.push(buildDefaultSlotProperty(void 0, children));
3693
- else if (implicitDefaultChildren.length && !implicitDefaultChildren.every(isWhitespaceText)) if (hasNamedDefaultSlot) context.onError(createCompilerError(39, implicitDefaultChildren[0].loc));
3694
- else slotsProperties.push(buildDefaultSlotProperty(void 0, implicitDefaultChildren));
3725
+ else if (implicitDefaultChildren.length && !implicitDefaultChildren.every(isWhitespaceText)) {
3726
+ if (hasNamedDefaultSlot) context.onError(createCompilerError(39, implicitDefaultChildren[0].loc));
3727
+ else slotsProperties.push(buildDefaultSlotProperty(void 0, implicitDefaultChildren));
3728
+ }
3695
3729
  }
3696
3730
  const slotFlag = hasDynamicSlots ? 2 : hasForwardedSlots(node.children) ? 3 : 1;
3697
3731
  let slots = createObjectExpression(slotsProperties.concat(createObjectProperty(`_`, createSimpleExpression(slotFlag + ` /* ${slotFlagsText[slotFlag]} */`, false))), loc);
@@ -3717,10 +3751,7 @@ function hasForwardedSlots(children) {
3717
3751
  if (hasForwardedSlots(child.branches)) return true;
3718
3752
  break;
3719
3753
  case 10:
3720
- case 11:
3721
- if (hasForwardedSlots(child.children)) return true;
3722
- break;
3723
- default: break;
3754
+ case 11: if (hasForwardedSlots(child.children)) return true;
3724
3755
  }
3725
3756
  }
3726
3757
  return false;
@@ -3742,12 +3773,16 @@ const transformElement = (node, context) => {
3742
3773
  let vnodeDynamicProps;
3743
3774
  let dynamicPropNames;
3744
3775
  let vnodeDirectives;
3776
+ let needsPatch = false;
3777
+ let isBlockRequired = false;
3745
3778
  let shouldUseBlock = isDynamicComponent || vnodeTag === TELEPORT || vnodeTag === SUSPENSE || !isComponent && (tag === "svg" || tag === "foreignObject" || tag === "math");
3746
3779
  if (props.length > 0) {
3747
3780
  const propsBuildResult = buildProps(node, context, void 0, isComponent, isDynamicComponent);
3748
3781
  vnodeProps = propsBuildResult.props;
3749
3782
  patchFlag = propsBuildResult.patchFlag;
3750
3783
  dynamicPropNames = propsBuildResult.dynamicPropNames;
3784
+ needsPatch = propsBuildResult.needsPatch;
3785
+ isBlockRequired = propsBuildResult.isBlockRequired;
3751
3786
  const directives = propsBuildResult.directives;
3752
3787
  vnodeDirectives = directives && directives.length ? createArrayExpression(directives.map((dir) => buildDirectiveArgs(dir, context))) : void 0;
3753
3788
  if (propsBuildResult.shouldUseBlock) shouldUseBlock = true;
@@ -3776,7 +3811,10 @@ const transformElement = (node, context) => {
3776
3811
  } else vnodeChildren = node.children;
3777
3812
  }
3778
3813
  if (dynamicPropNames && dynamicPropNames.length) vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
3779
- node.codegenNode = createVNodeCall(context, vnodeTag, vnodeProps, vnodeChildren, patchFlag === 0 ? void 0 : patchFlag, vnodeDynamicProps, vnodeDirectives, !!shouldUseBlock, false, isComponent, node.loc);
3814
+ const vnodeCall = node.codegenNode = createVNodeCall(context, vnodeTag, vnodeProps, vnodeChildren, patchFlag === 0 ? void 0 : patchFlag, vnodeDynamicProps, vnodeDirectives, !!shouldUseBlock, false, isComponent, node.loc);
3815
+ needsPatch = needsPatch && (patchFlag === 0 || patchFlag === 32);
3816
+ if (needsPatch) vnodeCall.needsPatch = true;
3817
+ if (isBlockRequired) vnodeCall.isBlockRequired = true;
3780
3818
  };
3781
3819
  };
3782
3820
  function resolveComponentType(node, context, ssr = false) {
@@ -3810,6 +3848,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
3810
3848
  const runtimeDirectives = [];
3811
3849
  const hasChildren = children.length > 0;
3812
3850
  let shouldUseBlock = false;
3851
+ let isBlockRequired = false;
3813
3852
  let patchFlag = 0;
3814
3853
  let hasRef = false;
3815
3854
  let hasClassBinding = false;
@@ -3834,12 +3873,12 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
3834
3873
  const isEventHandler = isOn(name);
3835
3874
  if (isEventHandler && (!isComponent || isDynamicComponent) && name.toLowerCase() !== "onclick" && name !== "onUpdate:modelValue" && !isReservedProp(name)) hasHydrationEventBinding = true;
3836
3875
  if (isEventHandler && isReservedProp(name)) hasVnodeHook = true;
3876
+ if (name === "ref") hasRef = true;
3837
3877
  if (isEventHandler && value.type === 14) value = value.arguments[0];
3838
3878
  if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) return;
3839
- if (name === "ref") hasRef = true;
3840
- else if (name === "class") hasClassBinding = true;
3879
+ if (name === "class") hasClassBinding = true;
3841
3880
  else if (name === "style") hasStyleBinding = true;
3842
- else if (name !== "key" && !dynamicPropNames.includes(name)) dynamicPropNames.push(name);
3881
+ else if (name !== "ref" && name !== "key" && !dynamicPropNames.includes(name)) dynamicPropNames.push(name);
3843
3882
  if (isComponent && (name === "class" || name === "style") && !dynamicPropNames.includes(name)) dynamicPropNames.push(name);
3844
3883
  } else hasDynamicKeys = true;
3845
3884
  };
@@ -3865,33 +3904,38 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
3865
3904
  if (name === "once" || name === "memo") continue;
3866
3905
  if (name === "is" || isVBind && isStaticArgOf(arg, "is") && (isComponentTag(tag) || isCompatEnabled("COMPILER_IS_ON_ELEMENT", context))) continue;
3867
3906
  if (isVOn && ssr) continue;
3868
- if (isVBind && isStaticArgOf(arg, "key") || isVOn && hasChildren && isStaticArgOf(arg, "vue:before-update")) shouldUseBlock = true;
3907
+ if (isVBind && isStaticArgOf(arg, "key")) shouldUseBlock = true;
3908
+ if (isVOn && hasChildren && arg && isStaticExp(arg) && camelize(arg.content) === "vue:beforeUpdate") {
3909
+ shouldUseBlock = true;
3910
+ isBlockRequired = true;
3911
+ }
3869
3912
  if (isVBind && isStaticArgOf(arg, "ref")) pushRefVForMarker();
3870
3913
  if (!arg && (isVBind || isVOn)) {
3871
3914
  hasDynamicKeys = true;
3872
- if (exp) if (isVBind) {
3873
- pushMergeArg();
3874
- if (mergeArgs.some((arg) => {
3875
- if (arg.type === 15) return arg.properties.some(({ key }) => {
3876
- if (key.type !== 4 || !key.isStatic) return true;
3877
- return key.content !== "class" && key.content !== "style" && !isOn(key.content);
3878
- });
3879
- else return true;
3880
- })) checkCompatEnabled("COMPILER_V_BIND_OBJECT_ORDER", context, loc);
3881
- if (isCompatEnabled("COMPILER_V_BIND_OBJECT_ORDER", context)) {
3882
- mergeArgs.unshift(exp);
3883
- continue;
3884
- }
3885
- pushRefVForMarker();
3886
- pushMergeArg();
3887
- mergeArgs.push(exp);
3888
- } else pushMergeArg({
3889
- type: 14,
3890
- loc,
3891
- callee: context.helper(TO_HANDLERS),
3892
- arguments: isComponent ? [exp] : [exp, `true`]
3893
- });
3894
- else context.onError(createCompilerError(isVBind ? 34 : 35, loc));
3915
+ if (exp) {
3916
+ if (isVBind) {
3917
+ pushMergeArg();
3918
+ if (mergeArgs.some((arg) => {
3919
+ if (arg.type === 15) return arg.properties.some(({ key }) => {
3920
+ if (key.type !== 4 || !key.isStatic) return true;
3921
+ return key.content !== "class" && key.content !== "style" && !isOn(key.content);
3922
+ });
3923
+ else return true;
3924
+ })) checkCompatEnabled("COMPILER_V_BIND_OBJECT_ORDER", context, loc);
3925
+ if (isCompatEnabled("COMPILER_V_BIND_OBJECT_ORDER", context)) {
3926
+ mergeArgs.unshift(exp);
3927
+ continue;
3928
+ }
3929
+ pushRefVForMarker();
3930
+ pushMergeArg();
3931
+ mergeArgs.push(exp);
3932
+ } else pushMergeArg({
3933
+ type: 14,
3934
+ loc,
3935
+ callee: context.helper(TO_HANDLERS),
3936
+ arguments: isComponent ? [exp] : [exp, `true`]
3937
+ });
3938
+ } else context.onError(createCompilerError(isVBind ? 34 : 35, loc));
3895
3939
  continue;
3896
3940
  }
3897
3941
  if (isVBind && modifiers.some((mod) => mod.content === "prop")) patchFlag |= 32;
@@ -3907,7 +3951,10 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
3907
3951
  }
3908
3952
  } else if (!isBuiltInDirective(name)) {
3909
3953
  runtimeDirectives.push(prop);
3910
- if (hasChildren) shouldUseBlock = true;
3954
+ if (hasChildren) {
3955
+ shouldUseBlock = true;
3956
+ isBlockRequired = true;
3957
+ }
3911
3958
  }
3912
3959
  }
3913
3960
  }
@@ -3924,7 +3971,8 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
3924
3971
  if (dynamicPropNames.length) patchFlag |= 8;
3925
3972
  if (hasHydrationEventBinding) patchFlag |= 32;
3926
3973
  }
3927
- if (!shouldUseBlock && (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) patchFlag |= 512;
3974
+ const needsPatch = (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0);
3975
+ if (!shouldUseBlock && needsPatch) patchFlag |= 512;
3928
3976
  if (!context.inSSR && propsExpression) switch (propsExpression.type) {
3929
3977
  case 15:
3930
3978
  let classKeyIndex = -1;
@@ -3945,16 +3993,16 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
3945
3993
  } else propsExpression = createCallExpression(context.helper(NORMALIZE_PROPS), [propsExpression]);
3946
3994
  break;
3947
3995
  case 14: break;
3948
- default:
3949
- propsExpression = createCallExpression(context.helper(NORMALIZE_PROPS), [createCallExpression(context.helper(GUARD_REACTIVE_PROPS), [propsExpression])]);
3950
- break;
3996
+ default: propsExpression = createCallExpression(context.helper(NORMALIZE_PROPS), [createCallExpression(context.helper(GUARD_REACTIVE_PROPS), [propsExpression])]);
3951
3997
  }
3952
3998
  return {
3953
3999
  props: propsExpression,
3954
4000
  directives: runtimeDirectives,
3955
4001
  patchFlag,
3956
4002
  dynamicPropNames,
3957
- shouldUseBlock
4003
+ shouldUseBlock,
4004
+ needsPatch,
4005
+ isBlockRequired
3958
4006
  };
3959
4007
  }
3960
4008
  function dedupeProperties(properties) {
@@ -4051,10 +4099,12 @@ function processSlotOutlet(node, context) {
4051
4099
  for (let i = 0; i < node.props.length; i++) {
4052
4100
  const p = node.props[i];
4053
4101
  if (p.type === 6) {
4054
- if (p.value) if (p.name === "name") slotName = JSON.stringify(p.value.content);
4055
- else {
4056
- p.name = camelize(p.name);
4057
- nonNameProps.push(p);
4102
+ if (p.value) {
4103
+ if (p.name === "name") slotName = JSON.stringify(p.value.content);
4104
+ else {
4105
+ p.name = camelize(p.name);
4106
+ nonNameProps.push(p);
4107
+ }
4058
4108
  }
4059
4109
  } else if (p.name === "bind" && isStaticArgOf(p.arg, "name")) {
4060
4110
  if (p.exp) slotName = p.exp;
@@ -4080,17 +4130,18 @@ const transformOn = (dir, node, context, augmentor) => {
4080
4130
  const { loc, modifiers, arg } = dir;
4081
4131
  if (!dir.exp && !modifiers.length) context.onError(createCompilerError(35, loc));
4082
4132
  let eventName;
4083
- if (arg.type === 4) if (arg.isStatic) {
4084
- let rawName = arg.content;
4085
- if (rawName.startsWith("vnode")) context.onError(createCompilerError(52, arg.loc));
4086
- if (rawName.startsWith("vue:")) rawName = `vnode-${rawName.slice(4)}`;
4087
- eventName = createSimpleExpression(node.tagType !== 0 || rawName.startsWith("vnode") || !/[A-Z]/.test(rawName) ? toHandlerKey(camelize(rawName)) : `on:${rawName}`, true, arg.loc);
4088
- } else eventName = createCompoundExpression([
4089
- `${context.helperString(TO_HANDLER_KEY)}(`,
4090
- arg,
4091
- `)`
4092
- ]);
4093
- else {
4133
+ if (arg.type === 4) {
4134
+ if (arg.isStatic) {
4135
+ let rawName = arg.content;
4136
+ if (rawName.startsWith("vnode")) context.onError(createCompilerError(52, arg.loc));
4137
+ if (rawName.startsWith("vue:")) rawName = `vnode-${rawName.slice(4)}`;
4138
+ eventName = createSimpleExpression(node.tagType !== 0 || rawName.startsWith("vnode") || !/[A-Z]/.test(rawName) ? toHandlerKey(camelize(rawName)) : `on:${rawName}`, true, arg.loc);
4139
+ } else eventName = createCompoundExpression([
4140
+ `${context.helperString(TO_HANDLER_KEY)}(`,
4141
+ arg,
4142
+ `)`
4143
+ ]);
4144
+ } else {
4094
4145
  eventName = arg;
4095
4146
  eventName.children.unshift(`${context.helperString(TO_HANDLER_KEY)}(`);
4096
4147
  eventName.children.push(`)`);
@@ -4126,11 +4177,14 @@ const transformBind = (dir, _node, context) => {
4126
4177
  arg.children.unshift(`(`);
4127
4178
  arg.children.push(`) || ""`);
4128
4179
  } else if (!arg.isStatic) arg.content = arg.content ? `${arg.content} || ""` : `""`;
4129
- if (modifiers.some((mod) => mod.content === "camel")) if (arg.type === 4) if (arg.isStatic) arg.content = camelize(arg.content);
4130
- else arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
4131
- else {
4132
- arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
4133
- arg.children.push(`)`);
4180
+ if (modifiers.some((mod) => mod.content === "camel")) {
4181
+ if (arg.type === 4) {
4182
+ if (arg.isStatic) arg.content = camelize(arg.content);
4183
+ else arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
4184
+ } else {
4185
+ arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
4186
+ arg.children.push(`)`);
4187
+ }
4134
4188
  }
4135
4189
  if (!context.inSSR) {
4136
4190
  if (modifiers.some((mod) => mod.content === "prop")) injectPrefix(arg, ".");
@@ -4139,9 +4193,10 @@ const transformBind = (dir, _node, context) => {
4139
4193
  return { props: [createObjectProperty(arg, exp)] };
4140
4194
  };
4141
4195
  const injectPrefix = (arg, prefix) => {
4142
- if (arg.type === 4) if (arg.isStatic) arg.content = prefix + arg.content;
4143
- else arg.content = `\`${prefix}\${${arg.content}}\``;
4144
- else {
4196
+ if (arg.type === 4) {
4197
+ if (arg.isStatic) arg.content = prefix + arg.content;
4198
+ else arg.content = `\`${prefix}\${${arg.content}}\``;
4199
+ } else {
4145
4200
  arg.children.unshift(`'${prefix}' + (`);
4146
4201
  arg.children.push(`)`);
4147
4202
  }
@@ -4262,7 +4317,7 @@ function rewriteFilter(node, context) {
4262
4317
  const child = node.children[i];
4263
4318
  if (typeof child !== "object") continue;
4264
4319
  if (child.type === 4) parseFilter(child, context);
4265
- else if (child.type === 8) rewriteFilter(node, context);
4320
+ else if (child.type === 8) rewriteFilter(child, context);
4266
4321
  else if (child.type === 5) rewriteFilter(child.content, context);
4267
4322
  }
4268
4323
  }
@@ -4288,11 +4343,12 @@ function parseFilter(node, context) {
4288
4343
  if (c === 96 && prev !== 92) inTemplateString = false;
4289
4344
  } else if (inRegex) {
4290
4345
  if (c === 47 && prev !== 92) inRegex = false;
4291
- } else if (c === 124 && exp.charCodeAt(i + 1) !== 124 && exp.charCodeAt(i - 1) !== 124 && !curly && !square && !paren) if (expression === void 0) {
4292
- lastFilterIndex = i + 1;
4293
- expression = exp.slice(0, i).trim();
4294
- } else pushFilter();
4295
- else {
4346
+ } else if (c === 124 && exp.charCodeAt(i + 1) !== 124 && exp.charCodeAt(i - 1) !== 124 && !curly && !square && !paren) {
4347
+ if (expression === void 0) {
4348
+ lastFilterIndex = i + 1;
4349
+ expression = exp.slice(0, i).trim();
4350
+ } else pushFilter();
4351
+ } else {
4296
4352
  switch (c) {
4297
4353
  case 34:
4298
4354
  inDouble = true;
@@ -4318,9 +4374,7 @@ function parseFilter(node, context) {
4318
4374
  case 123:
4319
4375
  curly++;
4320
4376
  break;
4321
- case 125:
4322
- curly--;
4323
- break;
4377
+ case 125: curly--;
4324
4378
  }
4325
4379
  if (c === 47) {
4326
4380
  let j = i - 1;
@@ -4636,9 +4690,7 @@ const transformModel$1 = (dir, node, context) => {
4636
4690
  isInvalidType = true;
4637
4691
  context.onError(createDOMCompilerError(60, dir.loc));
4638
4692
  break;
4639
- default:
4640
- checkDuplicatedValue();
4641
- break;
4693
+ default: checkDuplicatedValue();
4642
4694
  }
4643
4695
  } else if (hasDynamicKeyVBind(node)) directiveToUse = V_MODEL_DYNAMIC;
4644
4696
  else checkDuplicatedValue();
@@ -4651,27 +4703,37 @@ const transformModel$1 = (dir, node, context) => {
4651
4703
  };
4652
4704
  //#endregion
4653
4705
  //#region packages/compiler-dom/src/transforms/vOn.ts
4654
- const isEventOptionModifier = /* @__PURE__ */ makeMap(`passive,once,capture`);
4655
- const isNonKeyModifier = /* @__PURE__ */ makeMap("stop,prevent,self,ctrl,shift,alt,meta,exact,middle");
4656
- const maybeKeyModifier = /* @__PURE__ */ makeMap("left,right");
4657
- const isKeyboardEvent = /* @__PURE__ */ makeMap(`onkeyup,onkeydown,onkeypress`);
4706
+ const isEventOptionModifier = /*@__PURE__*/ makeMap(`passive,once,capture`);
4707
+ const isNonKeyModifier = /*@__PURE__*/ makeMap("stop,prevent,self,ctrl,shift,alt,meta,exact,middle");
4708
+ const maybeKeyModifier = /*@__PURE__*/ makeMap("left,right");
4709
+ const isKeyboardEvent = /*@__PURE__*/ makeMap(`onkeyup,onkeydown,onkeypress`);
4658
4710
  const resolveModifiers = (key, modifiers, context, loc) => {
4659
4711
  const keyModifiers = [];
4660
4712
  const nonKeyModifiers = [];
4661
4713
  const eventOptionModifiers = [];
4662
4714
  for (let i = 0; i < modifiers.length; i++) {
4663
4715
  const modifier = modifiers[i].content;
4716
+ if (modifier === "delegate") {
4717
+ if (context) {
4718
+ const error = /* @__PURE__ */ new SyntaxError(`.delegate modifier is only supported in Vapor components.`);
4719
+ error.loc = modifiers[i].loc;
4720
+ context.onWarn(error);
4721
+ }
4722
+ continue;
4723
+ }
4664
4724
  if (modifier === "native" && context && checkCompatEnabled("COMPILER_V_ON_NATIVE", context, loc)) eventOptionModifiers.push(modifier);
4665
4725
  else if (isEventOptionModifier(modifier)) eventOptionModifiers.push(modifier);
4666
4726
  else {
4667
4727
  const keyString = isString(key) ? key : isStaticExp(key) ? key.content : null;
4668
- if (maybeKeyModifier(modifier)) if (keyString) if (isKeyboardEvent(keyString.toLowerCase())) keyModifiers.push(modifier);
4669
- else nonKeyModifiers.push(modifier);
4670
- else {
4671
- keyModifiers.push(modifier);
4672
- nonKeyModifiers.push(modifier);
4673
- }
4674
- else if (isNonKeyModifier(modifier)) nonKeyModifiers.push(modifier);
4728
+ if (maybeKeyModifier(modifier)) {
4729
+ if (keyString) {
4730
+ if (isKeyboardEvent(keyString.toLowerCase())) keyModifiers.push(modifier);
4731
+ else nonKeyModifiers.push(modifier);
4732
+ } else {
4733
+ keyModifiers.push(modifier);
4734
+ nonKeyModifiers.push(modifier);
4735
+ }
4736
+ } else if (isNonKeyModifier(modifier)) nonKeyModifiers.push(modifier);
4675
4737
  else keyModifiers.push(modifier);
4676
4738
  }
4677
4739
  }
@@ -4737,7 +4799,7 @@ function postTransformTransition(node, onError, hasMultipleChildren = defaultHas
4737
4799
  source: ""
4738
4800
  }));
4739
4801
  const child = node.children[0];
4740
- if (child.type === 1) {
4802
+ if (child.type === 1 && !findDir(child, "if")) {
4741
4803
  for (const p of child.props) if (p.type === 7 && p.name === "show") node.props.push({
4742
4804
  type: 6,
4743
4805
  name: "persisted",
@@ -4786,7 +4848,7 @@ function isValidHTMLNesting(parent, child) {
4786
4848
  }
4787
4849
  return true;
4788
4850
  }
4789
- const headings = new Set([
4851
+ const headings = /* @__PURE__ */ new Set([
4790
4852
  "h1",
4791
4853
  "h2",
4792
4854
  "h3",
@@ -4798,7 +4860,7 @@ const emptySet = /* @__PURE__ */ new Set([]);
4798
4860
  /**
4799
4861
  * maps element to set of elements that can be it's children, no other */
4800
4862
  const onlyValidChildren = {
4801
- head: new Set([
4863
+ head: /* @__PURE__ */ new Set([
4802
4864
  "base",
4803
4865
  "basefront",
4804
4866
  "bgsound",
@@ -4811,24 +4873,24 @@ const onlyValidChildren = {
4811
4873
  "script",
4812
4874
  "template"
4813
4875
  ]),
4814
- optgroup: new Set(["option"]),
4815
- select: new Set([
4876
+ optgroup: /* @__PURE__ */ new Set(["option"]),
4877
+ select: /* @__PURE__ */ new Set([
4816
4878
  "optgroup",
4817
4879
  "option",
4818
4880
  "hr"
4819
4881
  ]),
4820
- table: new Set([
4882
+ table: /* @__PURE__ */ new Set([
4821
4883
  "caption",
4822
4884
  "colgroup",
4823
4885
  "tbody",
4824
4886
  "tfoot",
4825
4887
  "thead"
4826
4888
  ]),
4827
- tr: new Set(["td", "th"]),
4828
- colgroup: new Set(["col"]),
4829
- tbody: new Set(["tr"]),
4830
- thead: new Set(["tr"]),
4831
- tfoot: new Set(["tr"]),
4889
+ tr: /* @__PURE__ */ new Set(["td", "th"]),
4890
+ colgroup: /* @__PURE__ */ new Set(["col"]),
4891
+ tbody: /* @__PURE__ */ new Set(["tr"]),
4892
+ thead: /* @__PURE__ */ new Set(["tr"]),
4893
+ tfoot: /* @__PURE__ */ new Set(["tr"]),
4832
4894
  script: emptySet,
4833
4895
  iframe: emptySet,
4834
4896
  option: emptySet,
@@ -4839,30 +4901,30 @@ const onlyValidChildren = {
4839
4901
  /** maps elements to set of elements which can be it's parent, no other */
4840
4902
  const onlyValidParents = {
4841
4903
  html: emptySet,
4842
- body: new Set(["html"]),
4843
- head: new Set(["html"]),
4844
- td: new Set(["tr"]),
4845
- colgroup: new Set(["table"]),
4846
- caption: new Set(["table"]),
4847
- tbody: new Set(["table"]),
4848
- tfoot: new Set(["table"]),
4849
- col: new Set(["colgroup"]),
4850
- th: new Set(["tr"]),
4851
- thead: new Set(["table"]),
4852
- tr: new Set([
4904
+ body: /* @__PURE__ */ new Set(["html"]),
4905
+ head: /* @__PURE__ */ new Set(["html"]),
4906
+ td: /* @__PURE__ */ new Set(["tr"]),
4907
+ colgroup: /* @__PURE__ */ new Set(["table"]),
4908
+ caption: /* @__PURE__ */ new Set(["table"]),
4909
+ tbody: /* @__PURE__ */ new Set(["table"]),
4910
+ tfoot: /* @__PURE__ */ new Set(["table"]),
4911
+ col: /* @__PURE__ */ new Set(["colgroup"]),
4912
+ th: /* @__PURE__ */ new Set(["tr"]),
4913
+ thead: /* @__PURE__ */ new Set(["table"]),
4914
+ tr: /* @__PURE__ */ new Set([
4853
4915
  "tbody",
4854
4916
  "thead",
4855
4917
  "tfoot"
4856
4918
  ]),
4857
- dd: new Set(["dl", "div"]),
4858
- dt: new Set(["dl", "div"]),
4859
- figcaption: new Set(["figure"]),
4860
- summary: new Set(["details"]),
4861
- area: new Set(["map"])
4919
+ dd: /* @__PURE__ */ new Set(["dl", "div"]),
4920
+ dt: /* @__PURE__ */ new Set(["dl", "div"]),
4921
+ figcaption: /* @__PURE__ */ new Set(["figure"]),
4922
+ summary: /* @__PURE__ */ new Set(["details"]),
4923
+ area: /* @__PURE__ */ new Set(["map"])
4862
4924
  };
4863
4925
  /** maps element to set of elements that can not be it's children, others can */
4864
4926
  const knownInvalidChildren = {
4865
- p: new Set([
4927
+ p: /* @__PURE__ */ new Set([
4866
4928
  "address",
4867
4929
  "article",
4868
4930
  "aside",
@@ -4897,7 +4959,7 @@ const knownInvalidChildren = {
4897
4959
  "table",
4898
4960
  "ul"
4899
4961
  ]),
4900
- svg: new Set([
4962
+ svg: /* @__PURE__ */ new Set([
4901
4963
  "b",
4902
4964
  "blockquote",
4903
4965
  "br",
@@ -4938,12 +5000,12 @@ const knownInvalidChildren = {
4938
5000
  };
4939
5001
  /** maps element to set of elements that can not be it's parent, others can */
4940
5002
  const knownInvalidParents = {
4941
- a: new Set(["a"]),
4942
- button: new Set(["button"]),
4943
- dd: new Set(["dd", "dt"]),
4944
- dt: new Set(["dd", "dt"]),
4945
- form: new Set(["form"]),
4946
- li: new Set(["li"]),
5003
+ a: /* @__PURE__ */ new Set(["a"]),
5004
+ button: /* @__PURE__ */ new Set(["button"]),
5005
+ dd: /* @__PURE__ */ new Set(["dd", "dt"]),
5006
+ dt: /* @__PURE__ */ new Set(["dd", "dt"]),
5007
+ form: /* @__PURE__ */ new Set(["form"]),
5008
+ li: /* @__PURE__ */ new Set(["li"]),
4947
5009
  h1: headings,
4948
5010
  h2: headings,
4949
5011
  h3: headings,