@vue/compiler-vapor 3.6.0-alpha.5 → 3.6.0-alpha.7

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-vapor v3.6.0-alpha.5
2
+ * @vue/compiler-vapor v3.6.0-alpha.7
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -24,8 +24,7 @@ const newBlock = (node) => ({
24
24
  effect: [],
25
25
  operation: [],
26
26
  returns: [],
27
- tempId: 0,
28
- hasDeferredVShow: false
27
+ tempId: 0
29
28
  });
30
29
  function wrapTemplate(node, dirs) {
31
30
  if (node.tagType === 3) {
@@ -286,7 +285,8 @@ function transform(node, options = {}) {
286
285
  component: /* @__PURE__ */ new Set(),
287
286
  directive: /* @__PURE__ */ new Set(),
288
287
  block: newBlock(node),
289
- hasTemplateRef: false
288
+ hasTemplateRef: false,
289
+ hasDeferredVShow: false
290
290
  };
291
291
  const context = new TransformContext(ir, node, options);
292
292
  transformNode(context);
@@ -1027,7 +1027,7 @@ function genSetEvent(oper, context) {
1027
1027
  const name = genName();
1028
1028
  const handler = [
1029
1029
  `${context.helper("createInvoker")}(`,
1030
- ...genEventHandler(context, value, modifiers),
1030
+ ...genEventHandler(context, [value], modifiers),
1031
1031
  `)`
1032
1032
  ];
1033
1033
  const eventOptions = genEventOptions();
@@ -1084,37 +1084,47 @@ function genSetDynamicEvents(oper, context) {
1084
1084
  )
1085
1085
  ];
1086
1086
  }
1087
- function genEventHandler(context, value, modifiers = { nonKeys: [], keys: [] }, extraWrap = false) {
1088
- let handlerExp = [`() => {}`];
1089
- if (value && value.content.trim()) {
1090
- if (compilerDom.isMemberExpression(value, context.options)) {
1091
- handlerExp = genExpression(value, context);
1092
- if (!isConstantBinding(value, context) && !extraWrap) {
1093
- const isTSNode = value.ast && compilerDom.TS_NODE_TYPES.includes(value.ast.type);
1094
- handlerExp = [
1095
- `e => `,
1096
- isTSNode ? "(" : "",
1097
- ...handlerExp,
1098
- isTSNode ? ")" : "",
1099
- `(e)`
1100
- ];
1087
+ function genEventHandler(context, values, modifiers = { nonKeys: [], keys: [] }, extraWrap = false) {
1088
+ let handlerExp = [];
1089
+ if (values) {
1090
+ values.forEach((value, index) => {
1091
+ let exp = [];
1092
+ if (value && value.content.trim()) {
1093
+ if (compilerDom.isMemberExpression(value, context.options)) {
1094
+ exp = genExpression(value, context);
1095
+ if (!isConstantBinding(value, context) && !extraWrap) {
1096
+ const isTSNode = value.ast && compilerDom.TS_NODE_TYPES.includes(value.ast.type);
1097
+ exp = [
1098
+ `e => `,
1099
+ isTSNode ? "(" : "",
1100
+ ...exp,
1101
+ isTSNode ? ")" : "",
1102
+ `(e)`
1103
+ ];
1104
+ }
1105
+ } else if (compilerDom.isFnExpression(value, context.options)) {
1106
+ exp = genExpression(value, context);
1107
+ } else {
1108
+ const referencesEvent = value.content.includes("$event");
1109
+ const hasMultipleStatements = value.content.includes(`;`);
1110
+ const expr = referencesEvent ? context.withId(() => genExpression(value, context), {
1111
+ $event: null
1112
+ }) : genExpression(value, context);
1113
+ exp = [
1114
+ referencesEvent ? "$event => " : "() => ",
1115
+ hasMultipleStatements ? "{" : "(",
1116
+ ...expr,
1117
+ hasMultipleStatements ? "}" : ")"
1118
+ ];
1119
+ }
1120
+ handlerExp = handlerExp.concat([index !== 0 ? ", " : "", ...exp]);
1101
1121
  }
1102
- } else if (compilerDom.isFnExpression(value, context.options)) {
1103
- handlerExp = genExpression(value, context);
1104
- } else {
1105
- const referencesEvent = value.content.includes("$event");
1106
- const hasMultipleStatements = value.content.includes(`;`);
1107
- const expr = referencesEvent ? context.withId(() => genExpression(value, context), {
1108
- $event: null
1109
- }) : genExpression(value, context);
1110
- handlerExp = [
1111
- referencesEvent ? "$event => " : "() => ",
1112
- hasMultipleStatements ? "{" : "(",
1113
- ...expr,
1114
- hasMultipleStatements ? "}" : ")"
1115
- ];
1122
+ });
1123
+ if (values.length > 1) {
1124
+ handlerExp = ["[", ...handlerExp, "]"];
1116
1125
  }
1117
1126
  }
1127
+ if (handlerExp.length === 0) handlerExp = ["() => {}"];
1118
1128
  const { keys, nonKeys } = modifiers;
1119
1129
  if (nonKeys.length)
1120
1130
  handlerExp = genWithModifiers(context, handlerExp, nonKeys);
@@ -1155,35 +1165,19 @@ function genFor(oper, context) {
1155
1165
  component,
1156
1166
  onlyChild
1157
1167
  } = oper;
1158
- let rawValue = null;
1168
+ const rawValue = value && value.content;
1159
1169
  const rawKey = key && key.content;
1160
1170
  const rawIndex = index && index.content;
1161
1171
  const sourceExpr = ["() => (", ...genExpression(source, context), ")"];
1162
- const idToPathMap = parseValueDestructure();
1172
+ const idToPathMap = parseValueDestructure(value, context);
1163
1173
  const [depth, exitScope] = context.enterScope();
1164
- const idMap = {};
1165
1174
  const itemVar = `_for_item${depth}`;
1175
+ const idMap = buildDestructureIdMap(
1176
+ idToPathMap,
1177
+ `${itemVar}.value`,
1178
+ context.options.expressionPlugins
1179
+ );
1166
1180
  idMap[itemVar] = null;
1167
- idToPathMap.forEach((pathInfo, id2) => {
1168
- let path = `${itemVar}.value${pathInfo ? pathInfo.path : ""}`;
1169
- if (pathInfo) {
1170
- if (pathInfo.helper) {
1171
- idMap[pathInfo.helper] = null;
1172
- path = `${pathInfo.helper}(${path}, ${pathInfo.helperArgs})`;
1173
- }
1174
- if (pathInfo.dynamic) {
1175
- const node = idMap[id2] = compilerDom.createSimpleExpression(path);
1176
- const plugins = context.options.expressionPlugins;
1177
- node.ast = parser.parseExpression(`(${path})`, {
1178
- plugins: plugins ? [...plugins, "typescript"] : ["typescript"]
1179
- });
1180
- } else {
1181
- idMap[id2] = path;
1182
- }
1183
- } else {
1184
- idMap[id2] = path;
1185
- }
1186
- });
1187
1181
  const args = [itemVar];
1188
1182
  if (rawKey) {
1189
1183
  const keyVar = `_for_key${depth}`;
@@ -1281,77 +1275,6 @@ function genFor(oper, context) {
1281
1275
  // todo: hydrationNode
1282
1276
  )
1283
1277
  ];
1284
- function parseValueDestructure() {
1285
- const map = /* @__PURE__ */ new Map();
1286
- if (value) {
1287
- rawValue = value && value.content;
1288
- if (value.ast) {
1289
- compilerDom.walkIdentifiers(
1290
- value.ast,
1291
- (id2, _, parentStack, ___, isLocal) => {
1292
- if (isLocal) {
1293
- let path = "";
1294
- let isDynamic = false;
1295
- let helper2;
1296
- let helperArgs;
1297
- for (let i = 0; i < parentStack.length; i++) {
1298
- const parent = parentStack[i];
1299
- const child = parentStack[i + 1] || id2;
1300
- if (parent.type === "ObjectProperty" && parent.value === child) {
1301
- if (parent.key.type === "StringLiteral") {
1302
- path += `[${JSON.stringify(parent.key.value)}]`;
1303
- } else if (parent.computed) {
1304
- isDynamic = true;
1305
- path += `[${value.content.slice(
1306
- parent.key.start - 1,
1307
- parent.key.end - 1
1308
- )}]`;
1309
- } else {
1310
- path += `.${parent.key.name}`;
1311
- }
1312
- } else if (parent.type === "ArrayPattern") {
1313
- const index2 = parent.elements.indexOf(child);
1314
- if (child.type === "RestElement") {
1315
- path += `.slice(${index2})`;
1316
- } else {
1317
- path += `[${index2}]`;
1318
- }
1319
- } else if (parent.type === "ObjectPattern" && child.type === "RestElement") {
1320
- helper2 = context.helper("getRestElement");
1321
- helperArgs = "[" + parent.properties.filter((p) => p.type === "ObjectProperty").map((p) => {
1322
- if (p.key.type === "StringLiteral") {
1323
- return JSON.stringify(p.key.value);
1324
- } else if (p.computed) {
1325
- isDynamic = true;
1326
- return value.content.slice(
1327
- p.key.start - 1,
1328
- p.key.end - 1
1329
- );
1330
- } else {
1331
- return JSON.stringify(p.key.name);
1332
- }
1333
- }).join(", ") + "]";
1334
- }
1335
- if (child.type === "AssignmentPattern" && (parent.type === "ObjectProperty" || parent.type === "ArrayPattern")) {
1336
- isDynamic = true;
1337
- helper2 = context.helper("getDefaultValue");
1338
- helperArgs = value.content.slice(
1339
- child.right.start - 1,
1340
- child.right.end - 1
1341
- );
1342
- }
1343
- }
1344
- map.set(id2.name, { path, dynamic: isDynamic, helper: helper2, helperArgs });
1345
- }
1346
- },
1347
- true
1348
- );
1349
- } else {
1350
- map.set(rawValue, null);
1351
- }
1352
- }
1353
- return map;
1354
- }
1355
1278
  function genCallback(expr) {
1356
1279
  if (!expr) return false;
1357
1280
  const res = context.withId(
@@ -1378,6 +1301,98 @@ function genFor(oper, context) {
1378
1301
  return idMap2;
1379
1302
  }
1380
1303
  }
1304
+ function parseValueDestructure(value, context) {
1305
+ const map = /* @__PURE__ */ new Map();
1306
+ if (value) {
1307
+ const rawValue = value.content;
1308
+ if (value.ast) {
1309
+ compilerDom.walkIdentifiers(
1310
+ value.ast,
1311
+ (id, _, parentStack, ___, isLocal) => {
1312
+ if (isLocal) {
1313
+ let path = "";
1314
+ let isDynamic = false;
1315
+ let helper;
1316
+ let helperArgs;
1317
+ for (let i = 0; i < parentStack.length; i++) {
1318
+ const parent = parentStack[i];
1319
+ const child = parentStack[i + 1] || id;
1320
+ if (parent.type === "ObjectProperty" && parent.value === child) {
1321
+ if (parent.key.type === "StringLiteral") {
1322
+ path += `[${JSON.stringify(parent.key.value)}]`;
1323
+ } else if (parent.computed) {
1324
+ isDynamic = true;
1325
+ path += `[${rawValue.slice(
1326
+ parent.key.start - 1,
1327
+ parent.key.end - 1
1328
+ )}]`;
1329
+ } else {
1330
+ path += `.${parent.key.name}`;
1331
+ }
1332
+ } else if (parent.type === "ArrayPattern") {
1333
+ const index = parent.elements.indexOf(child);
1334
+ if (child.type === "RestElement") {
1335
+ path += `.slice(${index})`;
1336
+ } else {
1337
+ path += `[${index}]`;
1338
+ }
1339
+ } else if (parent.type === "ObjectPattern" && child.type === "RestElement") {
1340
+ helper = context.helper("getRestElement");
1341
+ helperArgs = "[" + parent.properties.filter((p) => p.type === "ObjectProperty").map((p) => {
1342
+ if (p.key.type === "StringLiteral") {
1343
+ return JSON.stringify(p.key.value);
1344
+ } else if (p.computed) {
1345
+ isDynamic = true;
1346
+ return rawValue.slice(p.key.start - 1, p.key.end - 1);
1347
+ } else {
1348
+ return JSON.stringify(p.key.name);
1349
+ }
1350
+ }).join(", ") + "]";
1351
+ }
1352
+ if (child.type === "AssignmentPattern" && (parent.type === "ObjectProperty" || parent.type === "ArrayPattern")) {
1353
+ isDynamic = true;
1354
+ helper = context.helper("getDefaultValue");
1355
+ helperArgs = rawValue.slice(
1356
+ child.right.start - 1,
1357
+ child.right.end - 1
1358
+ );
1359
+ }
1360
+ }
1361
+ map.set(id.name, { path, dynamic: isDynamic, helper, helperArgs });
1362
+ }
1363
+ },
1364
+ true
1365
+ );
1366
+ } else if (rawValue) {
1367
+ map.set(rawValue, null);
1368
+ }
1369
+ }
1370
+ return map;
1371
+ }
1372
+ function buildDestructureIdMap(idToPathMap, baseAccessor, plugins) {
1373
+ const idMap = {};
1374
+ idToPathMap.forEach((pathInfo, id) => {
1375
+ let path = baseAccessor;
1376
+ if (pathInfo) {
1377
+ path = `${baseAccessor}${pathInfo.path}`;
1378
+ if (pathInfo.helper) {
1379
+ idMap[pathInfo.helper] = null;
1380
+ path = pathInfo.helperArgs ? `${pathInfo.helper}(${path}, ${pathInfo.helperArgs})` : `${pathInfo.helper}(${path})`;
1381
+ }
1382
+ if (pathInfo.dynamic) {
1383
+ const node = idMap[id] = compilerDom.createSimpleExpression(path);
1384
+ node.ast = parser.parseExpression(`(${path})`, {
1385
+ plugins: plugins ? [...plugins, "typescript"] : ["typescript"]
1386
+ });
1387
+ } else {
1388
+ idMap[id] = path;
1389
+ }
1390
+ } else {
1391
+ idMap[id] = path;
1392
+ }
1393
+ });
1394
+ return idMap;
1395
+ }
1381
1396
  function matchPatterns(render, keyProp, idMap) {
1382
1397
  const selectorPatterns = [];
1383
1398
  const keyOnlyBindingPatterns = [];
@@ -1618,6 +1633,7 @@ function genPropKey({ key: node, modifier, runtimeCamelize, handler, handlerModi
1618
1633
  }
1619
1634
  let key = genExpression(node, context);
1620
1635
  if (runtimeCamelize) {
1636
+ key.push(' || ""');
1621
1637
  key = genCall(helper("camelize"), key);
1622
1638
  }
1623
1639
  if (handler) {
@@ -1859,7 +1875,7 @@ function genCreateComponent(operation, context) {
1859
1875
  const rawProps = context.withId(() => genRawProps(props, context), ids);
1860
1876
  const inlineHandlers = handlers.reduce(
1861
1877
  (acc, { name, value }) => {
1862
- const handler = genEventHandler(context, value, void 0, false);
1878
+ const handler = genEventHandler(context, [value], void 0, false);
1863
1879
  return [...acc, `const ${name} = `, ...handler, NEWLINE];
1864
1880
  },
1865
1881
  []
@@ -1993,7 +2009,7 @@ function genProp(prop, context, isStatic) {
1993
2009
  ": ",
1994
2010
  ...prop.handler ? genEventHandler(
1995
2011
  context,
1996
- prop.values[0],
2012
+ prop.values,
1997
2013
  prop.handlerModifiers,
1998
2014
  true
1999
2015
  ) : isStatic ? ["() => (", ...values, ")"] : values,
@@ -2121,35 +2137,29 @@ function genConditionalSlot(slot, context) {
2121
2137
  ];
2122
2138
  }
2123
2139
  function genSlotBlockWithProps(oper, context) {
2124
- let isDestructureAssignment = false;
2125
- let rawProps;
2126
2140
  let propsName;
2127
2141
  let exitScope;
2128
2142
  let depth;
2129
2143
  const { props, key, node } = oper;
2130
- const idsOfProps = /* @__PURE__ */ new Set();
2144
+ const idToPathMap = props ? parseValueDestructure(props, context) : /* @__PURE__ */ new Map();
2131
2145
  if (props) {
2132
- rawProps = props.content;
2133
- if (isDestructureAssignment = !!props.ast) {
2146
+ if (props.ast) {
2134
2147
  [depth, exitScope] = context.enterScope();
2135
2148
  propsName = `_slotProps${depth}`;
2136
- compilerDom.walkIdentifiers(
2137
- props.ast,
2138
- (id, _, __, ___, isLocal) => {
2139
- if (isLocal) idsOfProps.add(id.name);
2140
- },
2141
- true
2142
- );
2143
2149
  } else {
2144
- idsOfProps.add(propsName = rawProps);
2150
+ propsName = props.content;
2145
2151
  }
2146
2152
  }
2147
- const idMap = {};
2148
- idsOfProps.forEach(
2149
- (id) => idMap[id] = isDestructureAssignment ? `${propsName}[${JSON.stringify(id)}]` : null
2150
- );
2153
+ const idMap = idToPathMap.size ? buildDestructureIdMap(
2154
+ idToPathMap,
2155
+ propsName || "",
2156
+ context.options.expressionPlugins
2157
+ ) : {};
2158
+ if (propsName) {
2159
+ idMap[propsName] = null;
2160
+ }
2151
2161
  let blockFn = context.withId(
2152
- () => genBlock(oper, context, [propsName]),
2162
+ () => genBlock(oper, context, propsName ? [propsName] : []),
2153
2163
  idMap
2154
2164
  );
2155
2165
  exitScope && exitScope();
@@ -2169,15 +2179,70 @@ function genSlotBlockWithProps(oper, context) {
2169
2179
  `}`
2170
2180
  ];
2171
2181
  }
2172
- if (node.type === 1 && !isKeepAliveTag(node.tag)) {
2173
- blockFn = [`${context.helper("withVaporCtx")}(`, ...blockFn, `)`];
2182
+ if (node.type === 1) {
2183
+ if (needsVaporCtx(oper)) {
2184
+ blockFn = [`${context.helper("withVaporCtx")}(`, ...blockFn, `)`];
2185
+ }
2174
2186
  }
2175
2187
  return blockFn;
2176
2188
  }
2189
+ function needsVaporCtx(block) {
2190
+ return hasComponentOrSlotInBlock(block);
2191
+ }
2192
+ function hasComponentOrSlotInBlock(block) {
2193
+ if (hasComponentOrSlotInOperations(block.operation)) return true;
2194
+ return hasComponentOrSlotInDynamic(block.dynamic);
2195
+ }
2196
+ function hasComponentOrSlotInDynamic(dynamic) {
2197
+ if (dynamic.operation) {
2198
+ const type = dynamic.operation.type;
2199
+ if (type === 11 || type === 12) {
2200
+ return true;
2201
+ }
2202
+ if (type === 15) {
2203
+ if (hasComponentOrSlotInIf(dynamic.operation)) return true;
2204
+ }
2205
+ if (type === 16) {
2206
+ if (hasComponentOrSlotInBlock(dynamic.operation.render))
2207
+ return true;
2208
+ }
2209
+ }
2210
+ for (const child of dynamic.children) {
2211
+ if (hasComponentOrSlotInDynamic(child)) return true;
2212
+ }
2213
+ return false;
2214
+ }
2215
+ function hasComponentOrSlotInOperations(operations) {
2216
+ for (const op of operations) {
2217
+ switch (op.type) {
2218
+ case 11:
2219
+ case 12:
2220
+ return true;
2221
+ case 15:
2222
+ if (hasComponentOrSlotInIf(op)) return true;
2223
+ break;
2224
+ case 16:
2225
+ if (hasComponentOrSlotInBlock(op.render)) return true;
2226
+ break;
2227
+ }
2228
+ }
2229
+ return false;
2230
+ }
2231
+ function hasComponentOrSlotInIf(node) {
2232
+ if (hasComponentOrSlotInBlock(node.positive)) return true;
2233
+ if (node.negative) {
2234
+ if ("positive" in node.negative) {
2235
+ return hasComponentOrSlotInIf(node.negative);
2236
+ } else {
2237
+ return hasComponentOrSlotInBlock(node.negative);
2238
+ }
2239
+ }
2240
+ return false;
2241
+ }
2177
2242
 
2178
2243
  function genSlotOutlet(oper, context) {
2179
2244
  const { helper } = context;
2180
- const { id, name, fallback, noSlotted } = oper;
2245
+ const { id, name, fallback, noSlotted, once } = oper;
2181
2246
  const [frag, push] = buildCodeFragment();
2182
2247
  const nameExpr = name.isStatic ? genExpression(name, context) : ["() => (", ...genExpression(name, context), ")"];
2183
2248
  let fallbackArg;
@@ -2192,8 +2257,10 @@ function genSlotOutlet(oper, context) {
2192
2257
  nameExpr,
2193
2258
  genRawProps(oper.props, context) || "null",
2194
2259
  fallbackArg,
2195
- noSlotted && "true"
2260
+ noSlotted && "true",
2196
2261
  // noSlotted
2262
+ once && "true"
2263
+ // v-once
2197
2264
  )
2198
2265
  );
2199
2266
  return frag;
@@ -2443,9 +2510,6 @@ function genBlockContent(block, context, root, genEffectsExtraFrag) {
2443
2510
  const [frag, push] = buildCodeFragment();
2444
2511
  const { dynamic, effect, operation, returns, key } = block;
2445
2512
  const resetBlock = context.enterBlock(block);
2446
- if (block.hasDeferredVShow) {
2447
- push(NEWLINE, `const deferredApplyVShows = []`);
2448
- }
2449
2513
  if (root) {
2450
2514
  for (let name of context.ir.component) {
2451
2515
  const id = compilerDom.toValidAssetId(name, "component");
@@ -2474,7 +2538,7 @@ function genBlockContent(block, context, root, genEffectsExtraFrag) {
2474
2538
  }
2475
2539
  push(...genOperations(operation, context));
2476
2540
  push(...genEffects(effect, context, genEffectsExtraFrag));
2477
- if (block.hasDeferredVShow) {
2541
+ if (root && context.ir.hasDeferredVShow) {
2478
2542
  push(NEWLINE, `deferredApplyVShows.forEach(fn => fn())`);
2479
2543
  }
2480
2544
  if (dynamic.needsKey) {
@@ -2630,6 +2694,9 @@ function generate(ir, options = {}) {
2630
2694
  `const ${setTemplateRefIdent} = ${context.helper("createTemplateRefSetter")}()`
2631
2695
  );
2632
2696
  }
2697
+ if (ir.hasDeferredVShow) {
2698
+ push(NEWLINE, `const deferredApplyVShows = []`);
2699
+ }
2633
2700
  push(...genBlockContent(ir.block, context, true));
2634
2701
  push(INDENT_END, NEWLINE);
2635
2702
  if (!inline) {
@@ -2783,6 +2850,11 @@ const isReservedProp = /* @__PURE__ */ shared.makeMap(
2783
2850
  const transformElement = (node, context) => {
2784
2851
  let effectIndex = context.block.effect.length;
2785
2852
  const getEffectIndex = () => effectIndex++;
2853
+ let parentSlots;
2854
+ if (node.type === 1 && (node.tagType === 1 || context.options.isCustomElement(node.tag))) {
2855
+ parentSlots = context.slots;
2856
+ context.slots = [];
2857
+ }
2786
2858
  return function postTransformElement() {
2787
2859
  ({ node } = context);
2788
2860
  if (!(node.type === 1 && (node.tagType === 0 || node.tagType === 1)))
@@ -2816,6 +2888,9 @@ const transformElement = (node, context) => {
2816
2888
  getEffectIndex
2817
2889
  );
2818
2890
  }
2891
+ if (parentSlots) {
2892
+ context.slots = parentSlots;
2893
+ }
2819
2894
  };
2820
2895
  };
2821
2896
  function isSingleRoot(context) {
@@ -3090,7 +3165,7 @@ function dedupeProperties(results) {
3090
3165
  const name = prop.key.content;
3091
3166
  const existing = knownProps.get(name);
3092
3167
  if (existing && existing.handler === prop.handler) {
3093
- if (name === "style" || name === "class") {
3168
+ if (name === "style" || name === "class" || prop.handler) {
3094
3169
  mergePropValues(existing, prop);
3095
3170
  }
3096
3171
  } else {
@@ -3268,6 +3343,9 @@ const transformVOn = (dir, node, context) => {
3268
3343
  keyOverride = ["click", "contextmenu"];
3269
3344
  }
3270
3345
  }
3346
+ if (keyModifiers.length && compilerDom.isStaticExp(arg) && !compilerDom.isKeyboardEvent(`on${arg.content.toLowerCase()}`)) {
3347
+ keyModifiers.length = 0;
3348
+ }
3271
3349
  if (isComponent || isSlotOutlet) {
3272
3350
  const handler = exp || EMPTY_EXPRESSION;
3273
3351
  return {
@@ -3321,7 +3399,7 @@ const transformVShow = (dir, node, context) => {
3321
3399
  if (parentNode && parentNode.type === 1) {
3322
3400
  shouldDeferred = !!(isTransitionTag(parentNode.tag) && findProp(parentNode, "appear", false, true));
3323
3401
  if (shouldDeferred) {
3324
- context.parent.parent.block.hasDeferredVShow = true;
3402
+ context.ir.hasDeferredVShow = true;
3325
3403
  }
3326
3404
  }
3327
3405
  context.registerOperation({
@@ -3594,7 +3672,7 @@ function getSiblingIf(context, reverse) {
3594
3672
  let i = siblings.indexOf(context.node);
3595
3673
  while (reverse ? --i >= 0 : ++i < siblings.length) {
3596
3674
  sibling = siblings[i];
3597
- if (!isCommentLike(sibling)) {
3675
+ if (!compilerDom.isCommentOrWhitespace(sibling)) {
3598
3676
  break;
3599
3677
  }
3600
3678
  }
@@ -3604,9 +3682,6 @@ function getSiblingIf(context, reverse) {
3604
3682
  return sibling;
3605
3683
  }
3606
3684
  }
3607
- function isCommentLike(node) {
3608
- return node.type === 3 || node.type === 2 && !node.content.trim().length;
3609
- }
3610
3685
 
3611
3686
  const transformVIf = createStructuralDirectiveTransform(
3612
3687
  ["if", "else", "else-if"],
@@ -3830,7 +3905,8 @@ const transformSlotOutlet = (node, context) => {
3830
3905
  name: slotName,
3831
3906
  props: irProps,
3832
3907
  fallback,
3833
- noSlotted: !!(context.options.scopeId && !context.options.slotted)
3908
+ noSlotted: !!(context.options.scopeId && !context.options.slotted),
3909
+ once: context.inVOnce
3834
3910
  };
3835
3911
  };
3836
3912
  };
@@ -94,7 +94,6 @@ export interface BlockIRNode extends BaseIRNode {
94
94
  effect: IREffect[];
95
95
  operation: OperationNode[];
96
96
  returns: number[];
97
- hasDeferredVShow: boolean;
98
97
  }
99
98
  export interface RootIRNode {
100
99
  type: IRNodeTypes.ROOT;
@@ -107,6 +106,7 @@ export interface RootIRNode {
107
106
  directive: Set<string>;
108
107
  block: BlockIRNode;
109
108
  hasTemplateRef: boolean;
109
+ hasDeferredVShow: boolean;
110
110
  }
111
111
  export interface IfIRNode extends BaseIRNode {
112
112
  type: IRNodeTypes.IF;
@@ -241,6 +241,7 @@ export interface SlotOutletIRNode extends BaseIRNode {
241
241
  props: IRProps[];
242
242
  fallback?: BlockIRNode;
243
243
  noSlotted?: boolean;
244
+ once?: boolean;
244
245
  parent?: number;
245
246
  anchor?: number;
246
247
  append?: boolean;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-vapor v3.6.0-alpha.5
2
+ * @vue/compiler-vapor v3.6.0-alpha.7
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -21340,7 +21340,9 @@ const isNonKeyModifier = /* @__PURE__ */ makeMap(
21340
21340
  `stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
21341
21341
  );
21342
21342
  const maybeKeyModifier = /* @__PURE__ */ makeMap("left,right");
21343
- const isKeyboardEvent = /* @__PURE__ */ makeMap(`onkeyup,onkeydown,onkeypress`);
21343
+ const isKeyboardEvent = /* @__PURE__ */ makeMap(
21344
+ `onkeyup,onkeydown,onkeypress`
21345
+ );
21344
21346
  const resolveModifiers = (key, modifiers, context, loc) => {
21345
21347
  const keyModifiers = [];
21346
21348
  const nonKeyModifiers = [];
@@ -21596,8 +21598,7 @@ const newBlock = (node) => ({
21596
21598
  effect: [],
21597
21599
  operation: [],
21598
21600
  returns: [],
21599
- tempId: 0,
21600
- hasDeferredVShow: false
21601
+ tempId: 0
21601
21602
  });
21602
21603
  function wrapTemplate(node, dirs) {
21603
21604
  if (node.tagType === 3) {
@@ -21858,7 +21859,8 @@ function transform(node, options = {}) {
21858
21859
  component: /* @__PURE__ */ new Set(),
21859
21860
  directive: /* @__PURE__ */ new Set(),
21860
21861
  block: newBlock(node),
21861
- hasTemplateRef: false
21862
+ hasTemplateRef: false,
21863
+ hasDeferredVShow: false
21862
21864
  };
21863
21865
  const context = new TransformContext(ir, node, options);
21864
21866
  transformNode(context);
@@ -22599,7 +22601,7 @@ function genSetEvent(oper, context) {
22599
22601
  const name = genName();
22600
22602
  const handler = [
22601
22603
  `${context.helper("createInvoker")}(`,
22602
- ...genEventHandler(context, value, modifiers),
22604
+ ...genEventHandler(context, [value], modifiers),
22603
22605
  `)`
22604
22606
  ];
22605
22607
  const eventOptions = genEventOptions();
@@ -22656,37 +22658,47 @@ function genSetDynamicEvents(oper, context) {
22656
22658
  )
22657
22659
  ];
22658
22660
  }
22659
- function genEventHandler(context, value, modifiers = { nonKeys: [], keys: [] }, extraWrap = false) {
22660
- let handlerExp = [`() => {}`];
22661
- if (value && value.content.trim()) {
22662
- if (isMemberExpression$1(value, context.options)) {
22663
- handlerExp = genExpression(value, context);
22664
- if (!isConstantBinding(value, context) && !extraWrap) {
22665
- const isTSNode = value.ast && TS_NODE_TYPES.includes(value.ast.type);
22666
- handlerExp = [
22667
- `e => `,
22668
- isTSNode ? "(" : "",
22669
- ...handlerExp,
22670
- isTSNode ? ")" : "",
22671
- `(e)`
22672
- ];
22661
+ function genEventHandler(context, values, modifiers = { nonKeys: [], keys: [] }, extraWrap = false) {
22662
+ let handlerExp = [];
22663
+ if (values) {
22664
+ values.forEach((value, index) => {
22665
+ let exp = [];
22666
+ if (value && value.content.trim()) {
22667
+ if (isMemberExpression$1(value, context.options)) {
22668
+ exp = genExpression(value, context);
22669
+ if (!isConstantBinding(value, context) && !extraWrap) {
22670
+ const isTSNode = value.ast && TS_NODE_TYPES.includes(value.ast.type);
22671
+ exp = [
22672
+ `e => `,
22673
+ isTSNode ? "(" : "",
22674
+ ...exp,
22675
+ isTSNode ? ")" : "",
22676
+ `(e)`
22677
+ ];
22678
+ }
22679
+ } else if (isFnExpression(value, context.options)) {
22680
+ exp = genExpression(value, context);
22681
+ } else {
22682
+ const referencesEvent = value.content.includes("$event");
22683
+ const hasMultipleStatements = value.content.includes(`;`);
22684
+ const expr = referencesEvent ? context.withId(() => genExpression(value, context), {
22685
+ $event: null
22686
+ }) : genExpression(value, context);
22687
+ exp = [
22688
+ referencesEvent ? "$event => " : "() => ",
22689
+ hasMultipleStatements ? "{" : "(",
22690
+ ...expr,
22691
+ hasMultipleStatements ? "}" : ")"
22692
+ ];
22693
+ }
22694
+ handlerExp = handlerExp.concat([index !== 0 ? ", " : "", ...exp]);
22673
22695
  }
22674
- } else if (isFnExpression(value, context.options)) {
22675
- handlerExp = genExpression(value, context);
22676
- } else {
22677
- const referencesEvent = value.content.includes("$event");
22678
- const hasMultipleStatements = value.content.includes(`;`);
22679
- const expr = referencesEvent ? context.withId(() => genExpression(value, context), {
22680
- $event: null
22681
- }) : genExpression(value, context);
22682
- handlerExp = [
22683
- referencesEvent ? "$event => " : "() => ",
22684
- hasMultipleStatements ? "{" : "(",
22685
- ...expr,
22686
- hasMultipleStatements ? "}" : ")"
22687
- ];
22696
+ });
22697
+ if (values.length > 1) {
22698
+ handlerExp = ["[", ...handlerExp, "]"];
22688
22699
  }
22689
22700
  }
22701
+ if (handlerExp.length === 0) handlerExp = ["() => {}"];
22690
22702
  const { keys, nonKeys } = modifiers;
22691
22703
  if (nonKeys.length)
22692
22704
  handlerExp = genWithModifiers(context, handlerExp, nonKeys);
@@ -22727,35 +22739,19 @@ function genFor(oper, context) {
22727
22739
  component,
22728
22740
  onlyChild
22729
22741
  } = oper;
22730
- let rawValue = null;
22742
+ const rawValue = value && value.content;
22731
22743
  const rawKey = key && key.content;
22732
22744
  const rawIndex = index && index.content;
22733
22745
  const sourceExpr = ["() => (", ...genExpression(source, context), ")"];
22734
- const idToPathMap = parseValueDestructure();
22746
+ const idToPathMap = parseValueDestructure(value, context);
22735
22747
  const [depth, exitScope] = context.enterScope();
22736
- const idMap = {};
22737
22748
  const itemVar = `_for_item${depth}`;
22749
+ const idMap = buildDestructureIdMap(
22750
+ idToPathMap,
22751
+ `${itemVar}.value`,
22752
+ context.options.expressionPlugins
22753
+ );
22738
22754
  idMap[itemVar] = null;
22739
- idToPathMap.forEach((pathInfo, id2) => {
22740
- let path = `${itemVar}.value${pathInfo ? pathInfo.path : ""}`;
22741
- if (pathInfo) {
22742
- if (pathInfo.helper) {
22743
- idMap[pathInfo.helper] = null;
22744
- path = `${pathInfo.helper}(${path}, ${pathInfo.helperArgs})`;
22745
- }
22746
- if (pathInfo.dynamic) {
22747
- const node = idMap[id2] = createSimpleExpression(path);
22748
- const plugins = context.options.expressionPlugins;
22749
- node.ast = libExports.parseExpression(`(${path})`, {
22750
- plugins: plugins ? [...plugins, "typescript"] : ["typescript"]
22751
- });
22752
- } else {
22753
- idMap[id2] = path;
22754
- }
22755
- } else {
22756
- idMap[id2] = path;
22757
- }
22758
- });
22759
22755
  const args = [itemVar];
22760
22756
  if (rawKey) {
22761
22757
  const keyVar = `_for_key${depth}`;
@@ -22853,77 +22849,6 @@ function genFor(oper, context) {
22853
22849
  // todo: hydrationNode
22854
22850
  )
22855
22851
  ];
22856
- function parseValueDestructure() {
22857
- const map = /* @__PURE__ */ new Map();
22858
- if (value) {
22859
- rawValue = value && value.content;
22860
- if (value.ast) {
22861
- walkIdentifiers(
22862
- value.ast,
22863
- (id2, _, parentStack, ___, isLocal) => {
22864
- if (isLocal) {
22865
- let path = "";
22866
- let isDynamic = false;
22867
- let helper2;
22868
- let helperArgs;
22869
- for (let i = 0; i < parentStack.length; i++) {
22870
- const parent = parentStack[i];
22871
- const child = parentStack[i + 1] || id2;
22872
- if (parent.type === "ObjectProperty" && parent.value === child) {
22873
- if (parent.key.type === "StringLiteral") {
22874
- path += `[${JSON.stringify(parent.key.value)}]`;
22875
- } else if (parent.computed) {
22876
- isDynamic = true;
22877
- path += `[${value.content.slice(
22878
- parent.key.start - 1,
22879
- parent.key.end - 1
22880
- )}]`;
22881
- } else {
22882
- path += `.${parent.key.name}`;
22883
- }
22884
- } else if (parent.type === "ArrayPattern") {
22885
- const index2 = parent.elements.indexOf(child);
22886
- if (child.type === "RestElement") {
22887
- path += `.slice(${index2})`;
22888
- } else {
22889
- path += `[${index2}]`;
22890
- }
22891
- } else if (parent.type === "ObjectPattern" && child.type === "RestElement") {
22892
- helper2 = context.helper("getRestElement");
22893
- helperArgs = "[" + parent.properties.filter((p) => p.type === "ObjectProperty").map((p) => {
22894
- if (p.key.type === "StringLiteral") {
22895
- return JSON.stringify(p.key.value);
22896
- } else if (p.computed) {
22897
- isDynamic = true;
22898
- return value.content.slice(
22899
- p.key.start - 1,
22900
- p.key.end - 1
22901
- );
22902
- } else {
22903
- return JSON.stringify(p.key.name);
22904
- }
22905
- }).join(", ") + "]";
22906
- }
22907
- if (child.type === "AssignmentPattern" && (parent.type === "ObjectProperty" || parent.type === "ArrayPattern")) {
22908
- isDynamic = true;
22909
- helper2 = context.helper("getDefaultValue");
22910
- helperArgs = value.content.slice(
22911
- child.right.start - 1,
22912
- child.right.end - 1
22913
- );
22914
- }
22915
- }
22916
- map.set(id2.name, { path, dynamic: isDynamic, helper: helper2, helperArgs });
22917
- }
22918
- },
22919
- true
22920
- );
22921
- } else {
22922
- map.set(rawValue, null);
22923
- }
22924
- }
22925
- return map;
22926
- }
22927
22852
  function genCallback(expr) {
22928
22853
  if (!expr) return false;
22929
22854
  const res = context.withId(
@@ -22950,6 +22875,98 @@ function genFor(oper, context) {
22950
22875
  return idMap2;
22951
22876
  }
22952
22877
  }
22878
+ function parseValueDestructure(value, context) {
22879
+ const map = /* @__PURE__ */ new Map();
22880
+ if (value) {
22881
+ const rawValue = value.content;
22882
+ if (value.ast) {
22883
+ walkIdentifiers(
22884
+ value.ast,
22885
+ (id, _, parentStack, ___, isLocal) => {
22886
+ if (isLocal) {
22887
+ let path = "";
22888
+ let isDynamic = false;
22889
+ let helper;
22890
+ let helperArgs;
22891
+ for (let i = 0; i < parentStack.length; i++) {
22892
+ const parent = parentStack[i];
22893
+ const child = parentStack[i + 1] || id;
22894
+ if (parent.type === "ObjectProperty" && parent.value === child) {
22895
+ if (parent.key.type === "StringLiteral") {
22896
+ path += `[${JSON.stringify(parent.key.value)}]`;
22897
+ } else if (parent.computed) {
22898
+ isDynamic = true;
22899
+ path += `[${rawValue.slice(
22900
+ parent.key.start - 1,
22901
+ parent.key.end - 1
22902
+ )}]`;
22903
+ } else {
22904
+ path += `.${parent.key.name}`;
22905
+ }
22906
+ } else if (parent.type === "ArrayPattern") {
22907
+ const index = parent.elements.indexOf(child);
22908
+ if (child.type === "RestElement") {
22909
+ path += `.slice(${index})`;
22910
+ } else {
22911
+ path += `[${index}]`;
22912
+ }
22913
+ } else if (parent.type === "ObjectPattern" && child.type === "RestElement") {
22914
+ helper = context.helper("getRestElement");
22915
+ helperArgs = "[" + parent.properties.filter((p) => p.type === "ObjectProperty").map((p) => {
22916
+ if (p.key.type === "StringLiteral") {
22917
+ return JSON.stringify(p.key.value);
22918
+ } else if (p.computed) {
22919
+ isDynamic = true;
22920
+ return rawValue.slice(p.key.start - 1, p.key.end - 1);
22921
+ } else {
22922
+ return JSON.stringify(p.key.name);
22923
+ }
22924
+ }).join(", ") + "]";
22925
+ }
22926
+ if (child.type === "AssignmentPattern" && (parent.type === "ObjectProperty" || parent.type === "ArrayPattern")) {
22927
+ isDynamic = true;
22928
+ helper = context.helper("getDefaultValue");
22929
+ helperArgs = rawValue.slice(
22930
+ child.right.start - 1,
22931
+ child.right.end - 1
22932
+ );
22933
+ }
22934
+ }
22935
+ map.set(id.name, { path, dynamic: isDynamic, helper, helperArgs });
22936
+ }
22937
+ },
22938
+ true
22939
+ );
22940
+ } else if (rawValue) {
22941
+ map.set(rawValue, null);
22942
+ }
22943
+ }
22944
+ return map;
22945
+ }
22946
+ function buildDestructureIdMap(idToPathMap, baseAccessor, plugins) {
22947
+ const idMap = {};
22948
+ idToPathMap.forEach((pathInfo, id) => {
22949
+ let path = baseAccessor;
22950
+ if (pathInfo) {
22951
+ path = `${baseAccessor}${pathInfo.path}`;
22952
+ if (pathInfo.helper) {
22953
+ idMap[pathInfo.helper] = null;
22954
+ path = pathInfo.helperArgs ? `${pathInfo.helper}(${path}, ${pathInfo.helperArgs})` : `${pathInfo.helper}(${path})`;
22955
+ }
22956
+ if (pathInfo.dynamic) {
22957
+ const node = idMap[id] = createSimpleExpression(path);
22958
+ node.ast = libExports.parseExpression(`(${path})`, {
22959
+ plugins: plugins ? [...plugins, "typescript"] : ["typescript"]
22960
+ });
22961
+ } else {
22962
+ idMap[id] = path;
22963
+ }
22964
+ } else {
22965
+ idMap[id] = path;
22966
+ }
22967
+ });
22968
+ return idMap;
22969
+ }
22953
22970
  function matchPatterns(render, keyProp, idMap) {
22954
22971
  const selectorPatterns = [];
22955
22972
  const keyOnlyBindingPatterns = [];
@@ -23190,6 +23207,7 @@ function genPropKey({ key: node, modifier, runtimeCamelize, handler, handlerModi
23190
23207
  }
23191
23208
  let key = genExpression(node, context);
23192
23209
  if (runtimeCamelize) {
23210
+ key.push(' || ""');
23193
23211
  key = genCall(helper("camelize"), key);
23194
23212
  }
23195
23213
  if (handler) {
@@ -23431,7 +23449,7 @@ function genCreateComponent(operation, context) {
23431
23449
  const rawProps = context.withId(() => genRawProps(props, context), ids);
23432
23450
  const inlineHandlers = handlers.reduce(
23433
23451
  (acc, { name, value }) => {
23434
- const handler = genEventHandler(context, value, void 0, false);
23452
+ const handler = genEventHandler(context, [value], void 0, false);
23435
23453
  return [...acc, `const ${name} = `, ...handler, NEWLINE];
23436
23454
  },
23437
23455
  []
@@ -23565,7 +23583,7 @@ function genProp(prop, context, isStatic) {
23565
23583
  ": ",
23566
23584
  ...prop.handler ? genEventHandler(
23567
23585
  context,
23568
- prop.values[0],
23586
+ prop.values,
23569
23587
  prop.handlerModifiers,
23570
23588
  true
23571
23589
  ) : isStatic ? ["() => (", ...values, ")"] : values,
@@ -23693,35 +23711,29 @@ function genConditionalSlot(slot, context) {
23693
23711
  ];
23694
23712
  }
23695
23713
  function genSlotBlockWithProps(oper, context) {
23696
- let isDestructureAssignment = false;
23697
- let rawProps;
23698
23714
  let propsName;
23699
23715
  let exitScope;
23700
23716
  let depth;
23701
23717
  const { props, key, node } = oper;
23702
- const idsOfProps = /* @__PURE__ */ new Set();
23718
+ const idToPathMap = props ? parseValueDestructure(props, context) : /* @__PURE__ */ new Map();
23703
23719
  if (props) {
23704
- rawProps = props.content;
23705
- if (isDestructureAssignment = !!props.ast) {
23720
+ if (props.ast) {
23706
23721
  [depth, exitScope] = context.enterScope();
23707
23722
  propsName = `_slotProps${depth}`;
23708
- walkIdentifiers(
23709
- props.ast,
23710
- (id, _, __, ___, isLocal) => {
23711
- if (isLocal) idsOfProps.add(id.name);
23712
- },
23713
- true
23714
- );
23715
23723
  } else {
23716
- idsOfProps.add(propsName = rawProps);
23724
+ propsName = props.content;
23717
23725
  }
23718
23726
  }
23719
- const idMap = {};
23720
- idsOfProps.forEach(
23721
- (id) => idMap[id] = isDestructureAssignment ? `${propsName}[${JSON.stringify(id)}]` : null
23722
- );
23727
+ const idMap = idToPathMap.size ? buildDestructureIdMap(
23728
+ idToPathMap,
23729
+ propsName || "",
23730
+ context.options.expressionPlugins
23731
+ ) : {};
23732
+ if (propsName) {
23733
+ idMap[propsName] = null;
23734
+ }
23723
23735
  let blockFn = context.withId(
23724
- () => genBlock(oper, context, [propsName]),
23736
+ () => genBlock(oper, context, propsName ? [propsName] : []),
23725
23737
  idMap
23726
23738
  );
23727
23739
  exitScope && exitScope();
@@ -23741,15 +23753,70 @@ function genSlotBlockWithProps(oper, context) {
23741
23753
  `}`
23742
23754
  ];
23743
23755
  }
23744
- if (node.type === 1 && !isKeepAliveTag(node.tag)) {
23745
- blockFn = [`${context.helper("withVaporCtx")}(`, ...blockFn, `)`];
23756
+ if (node.type === 1) {
23757
+ if (needsVaporCtx(oper)) {
23758
+ blockFn = [`${context.helper("withVaporCtx")}(`, ...blockFn, `)`];
23759
+ }
23746
23760
  }
23747
23761
  return blockFn;
23748
23762
  }
23763
+ function needsVaporCtx(block) {
23764
+ return hasComponentOrSlotInBlock(block);
23765
+ }
23766
+ function hasComponentOrSlotInBlock(block) {
23767
+ if (hasComponentOrSlotInOperations(block.operation)) return true;
23768
+ return hasComponentOrSlotInDynamic(block.dynamic);
23769
+ }
23770
+ function hasComponentOrSlotInDynamic(dynamic) {
23771
+ if (dynamic.operation) {
23772
+ const type = dynamic.operation.type;
23773
+ if (type === 11 || type === 12) {
23774
+ return true;
23775
+ }
23776
+ if (type === 15) {
23777
+ if (hasComponentOrSlotInIf(dynamic.operation)) return true;
23778
+ }
23779
+ if (type === 16) {
23780
+ if (hasComponentOrSlotInBlock(dynamic.operation.render))
23781
+ return true;
23782
+ }
23783
+ }
23784
+ for (const child of dynamic.children) {
23785
+ if (hasComponentOrSlotInDynamic(child)) return true;
23786
+ }
23787
+ return false;
23788
+ }
23789
+ function hasComponentOrSlotInOperations(operations) {
23790
+ for (const op of operations) {
23791
+ switch (op.type) {
23792
+ case 11:
23793
+ case 12:
23794
+ return true;
23795
+ case 15:
23796
+ if (hasComponentOrSlotInIf(op)) return true;
23797
+ break;
23798
+ case 16:
23799
+ if (hasComponentOrSlotInBlock(op.render)) return true;
23800
+ break;
23801
+ }
23802
+ }
23803
+ return false;
23804
+ }
23805
+ function hasComponentOrSlotInIf(node) {
23806
+ if (hasComponentOrSlotInBlock(node.positive)) return true;
23807
+ if (node.negative) {
23808
+ if ("positive" in node.negative) {
23809
+ return hasComponentOrSlotInIf(node.negative);
23810
+ } else {
23811
+ return hasComponentOrSlotInBlock(node.negative);
23812
+ }
23813
+ }
23814
+ return false;
23815
+ }
23749
23816
 
23750
23817
  function genSlotOutlet(oper, context) {
23751
23818
  const { helper } = context;
23752
- const { id, name, fallback, noSlotted } = oper;
23819
+ const { id, name, fallback, noSlotted, once } = oper;
23753
23820
  const [frag, push] = buildCodeFragment();
23754
23821
  const nameExpr = name.isStatic ? genExpression(name, context) : ["() => (", ...genExpression(name, context), ")"];
23755
23822
  let fallbackArg;
@@ -23764,8 +23831,10 @@ function genSlotOutlet(oper, context) {
23764
23831
  nameExpr,
23765
23832
  genRawProps(oper.props, context) || "null",
23766
23833
  fallbackArg,
23767
- noSlotted && "true"
23834
+ noSlotted && "true",
23768
23835
  // noSlotted
23836
+ once && "true"
23837
+ // v-once
23769
23838
  )
23770
23839
  );
23771
23840
  return frag;
@@ -24015,9 +24084,6 @@ function genBlockContent(block, context, root, genEffectsExtraFrag) {
24015
24084
  const [frag, push] = buildCodeFragment();
24016
24085
  const { dynamic, effect, operation, returns, key } = block;
24017
24086
  const resetBlock = context.enterBlock(block);
24018
- if (block.hasDeferredVShow) {
24019
- push(NEWLINE, `const deferredApplyVShows = []`);
24020
- }
24021
24087
  if (root) {
24022
24088
  for (let name of context.ir.component) {
24023
24089
  const id = toValidAssetId(name, "component");
@@ -24046,7 +24112,7 @@ function genBlockContent(block, context, root, genEffectsExtraFrag) {
24046
24112
  }
24047
24113
  push(...genOperations(operation, context));
24048
24114
  push(...genEffects(effect, context, genEffectsExtraFrag));
24049
- if (block.hasDeferredVShow) {
24115
+ if (root && context.ir.hasDeferredVShow) {
24050
24116
  push(NEWLINE, `deferredApplyVShows.forEach(fn => fn())`);
24051
24117
  }
24052
24118
  if (dynamic.needsKey) {
@@ -24202,6 +24268,9 @@ function generate(ir, options = {}) {
24202
24268
  `const ${setTemplateRefIdent} = ${context.helper("createTemplateRefSetter")}()`
24203
24269
  );
24204
24270
  }
24271
+ if (ir.hasDeferredVShow) {
24272
+ push(NEWLINE, `const deferredApplyVShows = []`);
24273
+ }
24205
24274
  push(...genBlockContent(ir.block, context, true));
24206
24275
  push(INDENT_END, NEWLINE);
24207
24276
  if (!inline) {
@@ -24355,6 +24424,11 @@ const isReservedProp = /* @__PURE__ */ makeMap(
24355
24424
  const transformElement = (node, context) => {
24356
24425
  let effectIndex = context.block.effect.length;
24357
24426
  const getEffectIndex = () => effectIndex++;
24427
+ let parentSlots;
24428
+ if (node.type === 1 && (node.tagType === 1 || context.options.isCustomElement(node.tag))) {
24429
+ parentSlots = context.slots;
24430
+ context.slots = [];
24431
+ }
24358
24432
  return function postTransformElement() {
24359
24433
  ({ node } = context);
24360
24434
  if (!(node.type === 1 && (node.tagType === 0 || node.tagType === 1)))
@@ -24388,6 +24462,9 @@ const transformElement = (node, context) => {
24388
24462
  getEffectIndex
24389
24463
  );
24390
24464
  }
24465
+ if (parentSlots) {
24466
+ context.slots = parentSlots;
24467
+ }
24391
24468
  };
24392
24469
  };
24393
24470
  function isSingleRoot(context) {
@@ -24662,7 +24739,7 @@ function dedupeProperties(results) {
24662
24739
  const name = prop.key.content;
24663
24740
  const existing = knownProps.get(name);
24664
24741
  if (existing && existing.handler === prop.handler) {
24665
- if (name === "style" || name === "class") {
24742
+ if (name === "style" || name === "class" || prop.handler) {
24666
24743
  mergePropValues(existing, prop);
24667
24744
  }
24668
24745
  } else {
@@ -24827,6 +24904,9 @@ const transformVOn = (dir, node, context) => {
24827
24904
  keyOverride = ["click", "contextmenu"];
24828
24905
  }
24829
24906
  }
24907
+ if (keyModifiers.length && isStaticExp(arg) && !isKeyboardEvent(`on${arg.content.toLowerCase()}`)) {
24908
+ keyModifiers.length = 0;
24909
+ }
24830
24910
  if (isComponent || isSlotOutlet) {
24831
24911
  const handler = exp || EMPTY_EXPRESSION;
24832
24912
  return {
@@ -24880,7 +24960,7 @@ const transformVShow = (dir, node, context) => {
24880
24960
  if (parentNode && parentNode.type === 1) {
24881
24961
  shouldDeferred = !!(isTransitionTag(parentNode.tag) && findProp(parentNode, "appear", false, true));
24882
24962
  if (shouldDeferred) {
24883
- context.parent.parent.block.hasDeferredVShow = true;
24963
+ context.ir.hasDeferredVShow = true;
24884
24964
  }
24885
24965
  }
24886
24966
  context.registerOperation({
@@ -25153,7 +25233,7 @@ function getSiblingIf(context, reverse) {
25153
25233
  let i = siblings.indexOf(context.node);
25154
25234
  while (reverse ? --i >= 0 : ++i < siblings.length) {
25155
25235
  sibling = siblings[i];
25156
- if (!isCommentLike(sibling)) {
25236
+ if (!isCommentOrWhitespace(sibling)) {
25157
25237
  break;
25158
25238
  }
25159
25239
  }
@@ -25163,9 +25243,6 @@ function getSiblingIf(context, reverse) {
25163
25243
  return sibling;
25164
25244
  }
25165
25245
  }
25166
- function isCommentLike(node) {
25167
- return node.type === 3 || node.type === 2 && !node.content.trim().length;
25168
- }
25169
25246
 
25170
25247
  const transformVIf = createStructuralDirectiveTransform(
25171
25248
  ["if", "else", "else-if"],
@@ -25389,7 +25466,8 @@ const transformSlotOutlet = (node, context) => {
25389
25466
  name: slotName,
25390
25467
  props: irProps,
25391
25468
  fallback,
25392
- noSlotted: !!(context.options.scopeId && !context.options.slotted)
25469
+ noSlotted: !!(context.options.scopeId && !context.options.slotted),
25470
+ once: context.inVOnce
25393
25471
  };
25394
25472
  };
25395
25473
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-vapor",
3
- "version": "3.6.0-alpha.5",
3
+ "version": "3.6.0-alpha.7",
4
4
  "description": "@vue/compiler-vapor",
5
5
  "main": "dist/compiler-vapor.cjs.js",
6
6
  "module": "dist/compiler-vapor.esm-bundler.js",
@@ -45,7 +45,7 @@
45
45
  "@babel/parser": "^7.28.5",
46
46
  "estree-walker": "^2.0.2",
47
47
  "source-map-js": "^1.2.1",
48
- "@vue/compiler-dom": "3.6.0-alpha.5",
49
- "@vue/shared": "3.6.0-alpha.5"
48
+ "@vue/compiler-dom": "3.6.0-alpha.7",
49
+ "@vue/shared": "3.6.0-alpha.7"
50
50
  }
51
51
  }