@vue/compiler-sfc 3.6.0-rc.12 → 3.6.0-rc.13

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-sfc v3.6.0-rc.12
2
+ * @vue/compiler-sfc v3.6.0-rc.13
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -16000,7 +16000,7 @@ function mergeSourceMaps(scriptMap, templateMap, templateLineOffset) {
16000
16000
  }
16001
16001
  //#endregion
16002
16002
  //#region packages/compiler-sfc/src/index.ts
16003
- const version = "3.6.0-rc.12";
16003
+ const version = "3.6.0-rc.13";
16004
16004
  const parseCache = parseCache$1;
16005
16005
  const errorMessages = {
16006
16006
  ..._vue_compiler_dom.errorMessages,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-sfc v3.6.0-rc.12
2
+ * @vue/compiler-sfc v3.6.0-rc.13
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -352,8 +352,6 @@ const MATH_TAGS = "annotation,annotation-xml,maction,maligngroup,malignmark,math
352
352
  const VOID_TAGS = "area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr";
353
353
  const FORMATTING_TAGS = "a,b,big,code,em,font,i,nobr,s,small,strike,strong,tt,u";
354
354
  const ALWAYS_CLOSE_TAGS = "title,style,script,noscript,template,object,table,button,textarea,select,iframe,fieldset,form,foreignObject,desc,mi,mo,mn,ms,mtext,annotation-xml";
355
- const INLINE_TAGS = "a,abbr,acronym,b,bdi,bdo,big,br,button,canvas,cite,code,data,datalist,del,dfn,em,embed,i,iframe,img,input,ins,kbd,label,map,mark,meter,noscript,object,output,picture,progress,q,ruby,s,samp,script,select,small,span,strong,sub,sup,svg,textarea,time,u,tt,var,video";
356
- const BLOCK_TAGS = "address,article,aside,blockquote,dd,details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,li,main,menu,nav,ol,p,pre,section,table,ul";
357
355
  /**
358
356
  * Compiler only.
359
357
  * Do NOT use in runtime code paths unless behind `__DEV__` flag.
@@ -384,16 +382,6 @@ const isFormattingTag = /*@__PURE__*/ makeMap(FORMATTING_TAGS);
384
382
  * Do NOT use in runtime code paths unless behind `__DEV__` flag.
385
383
  */
386
384
  const isAlwaysCloseTag = /*@__PURE__*/ makeMap(ALWAYS_CLOSE_TAGS);
387
- /**
388
- * Compiler only.
389
- * Do NOT use in runtime code paths unless behind `__DEV__` flag.
390
- */
391
- const isInlineTag = /*@__PURE__*/ makeMap(INLINE_TAGS);
392
- /**
393
- * Compiler only.
394
- * Do NOT use in runtime code paths unless behind `__DEV__` flag.
395
- */
396
- const isBlockTag = /*@__PURE__*/ makeMap(BLOCK_TAGS);
397
385
  //#endregion
398
386
  //#region packages/shared/src/domAttrConfig.ts
399
387
  /**
@@ -25228,6 +25216,22 @@ function getBlockShape(block) {
25228
25216
  if (root && root.operation && root.operation.type === 15) return 2;
25229
25217
  return block.node.type === 1 && block.node.children.every((child) => child.type === 2 || child.type === 5) ? 2 : 1;
25230
25218
  }
25219
+ /** the number of `v-if` / `v-else-if` nodes in the chain starting at `head` */
25220
+ function getIfChainLength(head) {
25221
+ let length = 1;
25222
+ let negative = head.negative;
25223
+ while (negative && negative.type === 15) {
25224
+ length++;
25225
+ negative = negative.negative;
25226
+ }
25227
+ return length;
25228
+ }
25229
+ function isLongIfChain(head) {
25230
+ return getIfChainLength(head) - 1 > 10;
25231
+ }
25232
+ function isSlotTemplate(node) {
25233
+ return node.type === 1 && isTemplateNode(node) && node.props.some(isVSlot);
25234
+ }
25231
25235
  //#endregion
25232
25236
  //#region packages/compiler-vapor/src/transform.ts
25233
25237
  init_objectSpread2();
@@ -25259,11 +25263,14 @@ var TransformContext = class TransformContext {
25259
25263
  this.isLastEffectiveChild = true;
25260
25264
  this.isOnRightmostPath = true;
25261
25265
  this.isSingleRoot = false;
25266
+ this.isSlotRoot = false;
25262
25267
  this.templateCloseTags = void 0;
25263
25268
  this.templateCloseBlocks = false;
25269
+ this.templateScope = 0;
25264
25270
  this.globalId = 0;
25265
25271
  this.nextIdMap = null;
25266
25272
  this.ifIndex = 0;
25273
+ this.ifHeads = /* @__PURE__ */ new Map();
25267
25274
  this.increaseId = () => {
25268
25275
  const id = getNextId(this.nextIdMap, this.globalId);
25269
25276
  this.globalId = getNextId(this.nextIdMap, id + 1);
@@ -25318,8 +25325,10 @@ var TransformContext = class TransformContext {
25318
25325
  this.dynamic.flags |= 1;
25319
25326
  return this.dynamic.id = this.increaseId();
25320
25327
  }
25321
- nextIfIndex() {
25322
- return this.ifIndex++;
25328
+ nextIfIndex(count = 1) {
25329
+ const index = this.ifIndex;
25330
+ this.ifIndex += count;
25331
+ return index;
25323
25332
  }
25324
25333
  getTemplateNamespace() {
25325
25334
  return this.node.type === 1 ? this.node.ns : 0;
@@ -25394,6 +25403,7 @@ var TransformContext = class TransformContext {
25394
25403
  const isLastEffectiveChild = childInfo.isLastEffectiveChild[index];
25395
25404
  const isOnRightmostPath = this.isOnRightmostPath && isLastEffectiveChild;
25396
25405
  const isSingleRoot = this.isSingleRootChild(childInfo);
25406
+ const isSlotRoot = this.isSlotRootChild(childInfo);
25397
25407
  return Object.assign(Object.create(TransformContext.prototype), this, {
25398
25408
  node,
25399
25409
  parent: this,
@@ -25410,8 +25420,10 @@ var TransformContext = class TransformContext {
25410
25420
  isLastEffectiveChild,
25411
25421
  isOnRightmostPath,
25412
25422
  isSingleRoot,
25423
+ isSlotRoot,
25413
25424
  templateCloseTags: this.templateCloseTags,
25414
- templateCloseBlocks: this.templateCloseBlocks
25425
+ templateCloseBlocks: this.templateCloseBlocks,
25426
+ templateScope: 0
25415
25427
  });
25416
25428
  }
25417
25429
  shiftEffectBoundaries(index, dynamic = this.dynamic) {
@@ -25424,6 +25436,7 @@ var TransformContext = class TransformContext {
25424
25436
  if (node.type !== 0 && node.type !== 1) return {
25425
25437
  node,
25426
25438
  hasSingleRootChild: true,
25439
+ hasSingleSlotRootChild: false,
25427
25440
  isLastEffectiveChild: []
25428
25441
  };
25429
25442
  const cached = childContextInfoCache.get(this);
@@ -25435,18 +25448,29 @@ var TransformContext = class TransformContext {
25435
25448
  isLastEffectiveChild[i] = !hasFollowingEffectiveChild;
25436
25449
  if (!isComponentChild(children[i])) hasFollowingEffectiveChild = true;
25437
25450
  }
25451
+ const hasSingleRoot = hasSingleRootChild(children);
25438
25452
  const childInfo = {
25439
25453
  node,
25440
- hasSingleRootChild: hasSingleRootChild(children),
25454
+ hasSingleRootChild: hasSingleRoot,
25455
+ hasSingleSlotRootChild: node.type === 1 && node.tagType === 1 && !isBuiltInComponent(node.tag) && (children.some(isSlotTemplate) ? hasSingleRootChild(children.filter((child) => !isSlotTemplate(child))) : hasSingleRoot),
25441
25456
  isLastEffectiveChild
25442
25457
  };
25443
25458
  childContextInfoCache.set(this, childInfo);
25444
25459
  return childInfo;
25445
25460
  }
25461
+ isSlotRootChild(childInfo) {
25462
+ const node = this.node;
25463
+ if (node.type !== 1) return false;
25464
+ if (node.tagType === 1) return childInfo.hasSingleSlotRootChild;
25465
+ return node.tagType === 3 && childInfo.hasSingleRootChild && (isSlotTemplate(node) || this.isSlotRoot && !findDir$1(node, "for"));
25466
+ }
25446
25467
  isSingleRootChild(childInfo) {
25447
- if (this.inVFor || !childInfo.hasSingleRootChild) return false;
25448
- if (this.node.type === 0) return true;
25449
- return this.node.type === 1 && (this.node.tagType === 3 || isTransitionNode(this.node) || isKeepAliveTag(this.node.tag)) && !!this.parent && this.isSingleRoot;
25468
+ if (!childInfo.hasSingleRootChild) return false;
25469
+ const node = this.node;
25470
+ if (node.type === 0) return true;
25471
+ if (node.type !== 1 || !this.parent) return false;
25472
+ if (node.tagType === 3) return this.isSingleRoot && !findDir$1(node, "for");
25473
+ return isTransitionNode(node) || isKeepAliveTag(node.tag);
25450
25474
  }
25451
25475
  };
25452
25476
  function hasSingleRootChild(children) {
@@ -25508,9 +25532,17 @@ function transform(node, options = {}) {
25508
25532
  };
25509
25533
  const context = new TransformContext(ir, node, options);
25510
25534
  transformNode(context);
25535
+ finalizeIfChains(context);
25511
25536
  ir.node.imports = context.imports;
25512
25537
  return ir;
25513
25538
  }
25539
+ function finalizeIfChains(context) {
25540
+ context.ifHeads.forEach((inVOnce, head) => {
25541
+ if (!isLongIfChain(head)) return;
25542
+ head.once = inVOnce;
25543
+ if (!inVOnce) head.index = context.nextIfIndex(Math.ceil((getIfChainLength(head) + 1) / 2));
25544
+ });
25545
+ }
25514
25546
  function transformNode(context) {
25515
25547
  let { node } = context;
25516
25548
  const { nodeTransforms } = context.options;
@@ -25833,7 +25865,11 @@ function genIdentifier(raw, context, loc, assignment, id, parent, parentStack, s
25833
25865
  -2,
25834
25866
  loc
25835
25867
  ]];
25836
- } else return genExpression(replacement, context, assignment);
25868
+ } else {
25869
+ const exp = genExpression(replacement, context, assignment);
25870
+ if (parent && parent.type === "ObjectProperty" && parent.shorthand) return [`${name}: `, ...exp];
25871
+ return exp;
25872
+ }
25837
25873
  }
25838
25874
  let prefix;
25839
25875
  let type = bindingMetadata && bindingMetadata[raw];
@@ -26805,6 +26841,7 @@ function genSetHtml(oper, context) {
26805
26841
  //#endregion
26806
26842
  //#region packages/compiler-vapor/src/generators/if.ts
26807
26843
  function genIf(oper, context, isNested = false) {
26844
+ if (!isNested && isLongIfChain(oper)) return genIfChain(oper, context);
26808
26845
  const { helper } = context;
26809
26846
  const { condition, positive, negative, once, slotRoot, index, blockShape } = oper;
26810
26847
  const [frag, push] = buildCodeFragment();
@@ -26852,6 +26889,57 @@ function genBlockShapeName(flags) {
26852
26889
  }
26853
26890
  return "UNKNOWN";
26854
26891
  }
26892
+ function genIfChain(oper, context) {
26893
+ const { helper } = context;
26894
+ const [frag, push] = buildCodeFragment();
26895
+ const selector = ["() => ", INDENT_START];
26896
+ const blocks = [];
26897
+ const branchFlags = [];
26898
+ let slotRoot = false;
26899
+ let node = oper;
26900
+ for (let i = 0;; i++) {
26901
+ if (i > 0) selector.push(NEWLINE, ": ");
26902
+ selector.push("(", ...genExpression(node.condition, context), `) ? ${i}`);
26903
+ blocks.push(genBlock(node.positive, context));
26904
+ branchFlags.push(node.blockShape & 35);
26905
+ if (node.slotRoot) slotRoot = true;
26906
+ const { negative } = node;
26907
+ if (negative && negative.type === 15) {
26908
+ node = negative;
26909
+ continue;
26910
+ }
26911
+ selector.push(NEWLINE, `: ${i + 1}`, INDENT_END);
26912
+ if (negative) blocks.push(genBlock(negative, context));
26913
+ branchFlags.push(node.blockShape >> 2 & 3 | (node.blockShape & 64 ? 32 : 0));
26914
+ break;
26915
+ }
26916
+ push(NEWLINE, `const n${oper.id} = `, ...genCall(helper("createIfChain"), selector, genMulti(DELIMITERS_ARRAY, ...blocks), genIfChainBranchFlags(branchFlags, blocks.length), genIfChainFlags(oper.once, slotRoot, oper.index)));
26917
+ return frag;
26918
+ }
26919
+ function genIfChainBranchFlags(branchFlags, blockCount) {
26920
+ if (branchFlags.every((flags, i) => flags === (i < blockCount ? 1 : 0))) return false;
26921
+ return genMulti(DELIMITERS_ARRAY, ...branchFlags.map((flags) => {
26922
+ const names = [genBlockShapeName(flags)];
26923
+ if (flags & 32) names.push("NO_SCOPE");
26924
+ return genFlags(flags, names);
26925
+ }));
26926
+ }
26927
+ function genIfChainFlags(once, slotRoot, index) {
26928
+ let flags = 0;
26929
+ const names = [];
26930
+ if (once) {
26931
+ flags |= 16;
26932
+ names.push("ONCE");
26933
+ } else {
26934
+ flags |= index + 1 << 8;
26935
+ names.push(`KEYED_INDEX_${index}`);
26936
+ }
26937
+ if (slotRoot) {
26938
+ flags |= 128;
26939
+ names.push("SLOT_ROOT");
26940
+ }
26941
+ return genFlags(flags, names);
26942
+ }
26855
26943
  //#endregion
26856
26944
  //#region packages/compiler-vapor/src/generators/prop.ts
26857
26945
  const helpers = {
@@ -27264,7 +27352,7 @@ function genCreateComponent(operation, context) {
27264
27352
  ", "
27265
27353
  ], ...slotDeclarations) : [],
27266
27354
  `const n${operation.id} = `,
27267
- ...genCall(isRuntimeDynamicComponent ? helper("createDynamicComponent") : operation.useCreateElement ? helper("createPlainElement") : useAssetComponentHelper ? helper("createAssetComponent") : operation.asset ? helper("createComponentWithFallback") : helper("createComponent"), tag, rawProps, rawSlots, isRuntimeDynamicComponent ? dynamicComponentFlags : root ? "true" : false, isRuntimeDynamicComponent ? operation.key && [
27355
+ ...genCall(isRuntimeDynamicComponent ? helper("createDynamicComponent") : operation.useCreateElement ? helper("createPlainElement") : useAssetComponentHelper ? helper("createAssetComponent") : operation.asset ? helper("createComponentWithFallback") : helper("createComponent"), tag, rawProps, rawSlots, isRuntimeDynamicComponent ? dynamicComponentFlags : root && (root === true ? "true" : genFlags(root, ["SLOT"])), isRuntimeDynamicComponent ? operation.key && [
27268
27356
  "() => (",
27269
27357
  ...genExpression(operation.key, context),
27270
27358
  ")"
@@ -27297,9 +27385,12 @@ function genCreateComponent(operation, context) {
27297
27385
  function genDynamicComponentFlags(root, once, slotRoot, ns) {
27298
27386
  let flags = 0;
27299
27387
  const names = [];
27300
- if (root) {
27388
+ if (root === true) {
27301
27389
  flags |= 1;
27302
27390
  names.push("SINGLE_ROOT");
27391
+ } else if (root) {
27392
+ flags |= 32;
27393
+ names.push("SLOT_SINGLE_ROOT");
27303
27394
  }
27304
27395
  if (once) {
27305
27396
  flags |= 2;
@@ -28480,6 +28571,94 @@ function genAssetImports({ ir }) {
28480
28571
  return imports;
28481
28572
  }
28482
28573
  //#endregion
28574
+ //#region packages/compiler-vapor/src/htmlNesting.ts
28575
+ const isPClosingTag = /*@__PURE__*/ makeMap("address,article,aside,blockquote,dd,details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,li,main,menu,nav,ol,p,pre,section,summary,table,ul");
28576
+ const isForeign = (ns) => ns !== 0;
28577
+ const isScopeBoundaryTag = /*@__PURE__*/ makeMap("caption,object,select,table,td,th");
28578
+ const isFormattingMarkerTag = /*@__PURE__*/ makeMap("caption,object,td,th");
28579
+ const isSpecialTag = /*@__PURE__*/ makeMap("address,area,article,aside,base,blockquote,body,br,button,caption,col,colgroup,dd,details,div,dl,dt,embed,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,iframe,img,input,li,link,main,menu,meta,nav,noscript,object,ol,p,param,pre,script,section,select,source,style,summary,table,tbody,td,template,textarea,tfoot,th,thead,title,tr,track,ul,wbr");
28580
+ const endsListItemSearch = (tag) => isSpecialTag(tag) && tag !== "address" && tag !== "div" && tag !== "p";
28581
+ /**
28582
+ * End tags with handling of their own pop whatever is still open below them.
28583
+ * Any other end tag is ignored when it meets a special element on its way up
28584
+ * the stack, and a formatting end tag runs the adoption agency around one, so
28585
+ * under those an open special descendant has to close itself.
28586
+ */
28587
+ const popsOpenDescendants = /*@__PURE__*/ makeMap("address,article,aside,blockquote,button,caption,colgroup,dd,details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,h1,h2,h3,h4,h5,h6,header,hgroup,li,main,menu,nav,object,ol,p,pre,section,summary,table,tbody,td,tfoot,th,thead,tr,ul");
28588
+ /**
28589
+ * Html start tags that end foreign content: the parser pops the open svg or
28590
+ * mathml elements and inserts these in the html namespace, while vdom creates
28591
+ * them in the foreign namespace their ast node carries. Only at html
28592
+ * integration points (`foreignObject`, `mi`, ...) do html children stay.
28593
+ */
28594
+ const isForeignBreakoutTag = /*@__PURE__*/ makeMap("b,blockquote,body,br,code,dd,div,dl,dt,em,embed,h1,h2,h3,h4,h5,h6,head,hr,i,img,li,menu,meta,ol,p,pre,ruby,s,small,span,strong,sub,sup,table,u,ul,var");
28595
+ /**
28596
+ * Table parts whose text content other than whitespace the parser
28597
+ * foster-parents in front of the table.
28598
+ */
28599
+ const isFosterParentingTag = /*@__PURE__*/ makeMap("colgroup,table,tbody,tfoot,thead,tr");
28600
+ const isImpliedEndTag = /*@__PURE__*/ makeMap("dd,dt,li,optgroup,option,p,rp,rt");
28601
+ /**
28602
+ * The scope the children of `tag` see, given the scope `tag` itself was
28603
+ * written in (0 when it starts a template).
28604
+ */
28605
+ function enterOpenScope(scope, tag, ns) {
28606
+ if (isForeign(ns)) {
28607
+ scope &= -104;
28608
+ return scope;
28609
+ }
28610
+ if (isScopeBoundaryTag(tag)) scope &= -8;
28611
+ if (isFormattingMarkerTag(tag)) scope &= -9;
28612
+ if (endsListItemSearch(tag)) scope &= -97;
28613
+ switch (tag) {
28614
+ case "p": return scope | 1;
28615
+ case "button": return scope & -2 | 2;
28616
+ case "ruby": return scope | 4;
28617
+ case "a": return scope | 8;
28618
+ case "form": return scope | 16;
28619
+ case "li": return scope | 32;
28620
+ case "dd":
28621
+ case "dt": return scope | 64;
28622
+ }
28623
+ return scope;
28624
+ }
28625
+ /**
28626
+ * Whether the html parser places an element written under `parent` there, so
28627
+ * that both can share a template string. Two layers: `isValidHTMLNesting`
28628
+ * rejects what the parent itself cannot hold (table, row, select and raw-text
28629
+ * content models, void parents), `closesOpenAncestor` the start tags that end
28630
+ * an element still open above. The end-tag omission in transformElement
28631
+ * assumes only elements passing both share a template.
28632
+ */
28633
+ function keepsInTemplate(tag, ns, parentTag, scope) {
28634
+ return isValidHTMLNesting(parentTag, tag) && !closesOpenAncestor(tag, ns, parentTag, scope);
28635
+ }
28636
+ /**
28637
+ * Whether the html parser, on the start tag of `tag`, closes an element that
28638
+ * is still open above it in the same template - the `<p>` of
28639
+ * `<p><span><div>`, the `<li>` of `<li><span><li>`, a link inside a link. The
28640
+ * element would then end up elsewhere than the compiler expects, so it has to
28641
+ * go into a template of its own. Transcribed from the "in body" insertion mode
28642
+ * of https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inbody
28643
+ * for the native html tags the compiler knows; `scope` is what the parent
28644
+ * leaves open (`enterOpenScope`).
28645
+ */
28646
+ function closesOpenAncestor(tag, ns, parentTag, scope) {
28647
+ if (isForeign(ns)) return false;
28648
+ if (isPClosingTag(tag) && scope & 1) return true;
28649
+ switch (tag) {
28650
+ case "li": return !!(scope & 32);
28651
+ case "dd":
28652
+ case "dt": return !!(scope & 64);
28653
+ case "button": return !!(scope & 2);
28654
+ case "a": return !!(scope & 8);
28655
+ case "form": return !!(scope & 16);
28656
+ case "rt":
28657
+ case "rp": return !!(scope & 4) && isImpliedEndTag(parentTag);
28658
+ }
28659
+ return false;
28660
+ }
28661
+ //#endregion
28483
28662
  //#region packages/compiler-vapor/src/transforms/vBind.ts
28484
28663
  function normalizeBindShorthand(arg, context) {
28485
28664
  if (arg.type !== 4 || !arg.isStatic) {
@@ -28649,7 +28828,7 @@ const transformElement = (node, context) => {
28649
28828
  const staticKey = dynamicComponentKeys.has(node) ? void 0 : resolveStaticKey(node, context, isComponent);
28650
28829
  const propsResult = buildProps(node, context, isComponent, isDynamicComponent, getEffectIndex);
28651
28830
  const singleRoot = context.isSingleRoot;
28652
- if (isComponent) transformComponentElement(node, propsResult, staticKey, singleRoot, context, isDynamicComponent, useCreateElement);
28831
+ if (isComponent) transformComponentElement(node, propsResult, staticKey, singleRoot || context.isSlotRoot && !useCreateElement && 2, context, isDynamicComponent, useCreateElement);
28653
28832
  else transformNativeElement(node, propsResult, staticKey, singleRoot, context, getEffectIndex, context.root === context.effectiveParent || canOmitEndTag(node, context));
28654
28833
  if (parentSlots) context.slots = parentSlots;
28655
28834
  };
@@ -28658,7 +28837,7 @@ function canOmitEndTag(node, context) {
28658
28837
  const { block, parent } = context;
28659
28838
  if (!parent) return false;
28660
28839
  if (block !== parent.block) return true;
28661
- if (context.templateCloseTags && (context.templateCloseTags.has(node.tag) || context.templateCloseTags.has("form") || context.templateCloseTags.has("li") && (node.tag === "ul" || node.tag === "ol") || isAlwaysCloseTag(node.tag) || isFormattingTag(node.tag)) || context.templateCloseBlocks && isBlockTag(node.tag)) return false;
28840
+ if (context.templateCloseTags && (context.templateCloseTags.has(node.tag) || context.templateCloseTags.has("form") || context.templateCloseTags.has("li") && (node.tag === "ul" || node.tag === "ol") || isAlwaysCloseTag(node.tag) || isFormattingTag(node.tag)) || context.templateCloseBlocks && isSpecialTag(node.tag)) return false;
28662
28841
  if (isAlwaysCloseTag(node.tag) && !context.isOnRightmostPath) return false;
28663
28842
  if (isFormattingTag(node.tag) || parent.node.type === 1 && (node.tag === parent.node.tag || parent.node.ns !== 0 && node.ns !== parent.node.ns)) return context.isOnRightmostPath;
28664
28843
  return context.isLastEffectiveChild;
@@ -28666,9 +28845,8 @@ function canOmitEndTag(node, context) {
28666
28845
  function getChildTemplateCloseState(context) {
28667
28846
  const { node } = context;
28668
28847
  if (node.type !== 1 || node.tagType !== 0 || shouldUseCreateElement(node, context)) return;
28669
- const inSameTemplateAsParent = isInSameTemplateAsParent(context);
28670
- const inheritedTags = inSameTemplateAsParent ? context.templateCloseTags : void 0;
28671
- const inheritedBlocks = inSameTemplateAsParent && context.templateCloseBlocks;
28848
+ const inheritedTags = context.templateCloseTags;
28849
+ const inheritedBlocks = context.templateCloseBlocks;
28672
28850
  if (context.root === context.effectiveParent || canOmitEndTag(node, context) || isVoidTag(node.tag)) return inheritedTags || inheritedBlocks ? {
28673
28851
  tags: inheritedTags,
28674
28852
  blocks: inheritedBlocks
@@ -28677,20 +28855,23 @@ function getChildTemplateCloseState(context) {
28677
28855
  tags.add(node.tag);
28678
28856
  return {
28679
28857
  tags,
28680
- blocks: inheritedBlocks || isInlineTag(node.tag)
28858
+ blocks: !popsOpenDescendants(node.tag)
28681
28859
  };
28682
28860
  }
28683
- function isInSameTemplateAsParent(context) {
28684
- const { parent, node, block } = context;
28685
- if (!parent || block !== parent.block) return false;
28861
+ /**
28862
+ * The parent whose template string the element would be written into: a
28863
+ * plain element in the same block that is not created with createElement.
28864
+ */
28865
+ function getTemplateParent(context) {
28866
+ const { parent, block } = context;
28867
+ if (!parent || block !== parent.block) return;
28686
28868
  const parentNode = parent.node;
28687
- if (parentNode.type !== 1 || parentNode.tagType !== 0) return false;
28688
- return !shouldUseCreateElement(parentNode, parent) && isValidHTMLNesting(parentNode.tag, node.tag);
28869
+ if (parentNode.type === 1 && parentNode.tagType === 0 && !shouldUseCreateElement(parentNode, parent)) return parent;
28689
28870
  }
28690
- function transformComponentElement(node, propsResult, staticKey, singleRoot, context, isDynamicComponent, useCreateElement) {
28871
+ function transformComponentElement(node, propsResult, staticKey, root, context, isDynamicComponent, useCreateElement) {
28691
28872
  const dynamicComponent = isDynamicComponent ? resolveDynamicComponent(node) : void 0;
28692
28873
  let { tag } = node;
28693
- let asset = true;
28874
+ let asset = !useCreateElement;
28694
28875
  let slotScopeNamespace;
28695
28876
  if (!dynamicComponent && !useCreateElement) {
28696
28877
  const isProp = findProp(node, "is");
@@ -28738,7 +28919,7 @@ function transformComponentElement(node, propsResult, staticKey, singleRoot, con
28738
28919
  slotScopeNamespace,
28739
28920
  props,
28740
28921
  asset,
28741
- root: singleRoot,
28922
+ root,
28742
28923
  slots: [...context.slots],
28743
28924
  once: context.inVOnce,
28744
28925
  dynamic: dynamicComponent,
@@ -28903,7 +29084,7 @@ function transformNativeElement(node, propsResult, staticKey, singleRoot, contex
28903
29084
  template += `>` + children;
28904
29085
  if (!isVoidTag(tag) && !omitEndTag) template += `</${tag}>`;
28905
29086
  context.templateRoot = singleRoot;
28906
- if (context.parent && context.parent.node.type === 1 && !isValidHTMLNesting(context.parent.node.tag, tag)) {
29087
+ if (context.parent && context.parent.node.type === 1 && !isValidHTMLNesting(context.parent.node.tag, tag) || !(context.templateScope & 128) && getTemplateParent(context) !== void 0) {
28907
29088
  context.reference();
28908
29089
  context.dynamic.template = context.pushTemplate(template);
28909
29090
  context.dynamic.flags |= 6;
@@ -29420,7 +29601,7 @@ function mergePropValues(existing, incoming) {
29420
29601
  existing.values.push(...newValues);
29421
29602
  }
29422
29603
  function shouldUseCreateElement(node, context) {
29423
- return context.options.isCustomElement(node.tag) || node.tagType === 0 && node.tag === "template";
29604
+ return context.options.isCustomElement(node.tag) || node.tagType === 0 && (node.tag === "template" || node.ns !== 0 && isForeignBreakoutTag(node.tag));
29424
29605
  }
29425
29606
  //#endregion
29426
29607
  //#region packages/compiler-vapor/src/transforms/transformChildren.ts
@@ -29428,12 +29609,16 @@ const transformChildren = (node, context) => {
29428
29609
  const isFragment = node.type === 0 || node.type === 1 && (node.tagType === 3 || node.tagType === 1);
29429
29610
  if (!isFragment && node.type !== 1) return;
29430
29611
  const useCreateElement = node.type === 1 && shouldUseCreateElement(node, context);
29431
- const childTemplateCloseState = !isFragment && !useCreateElement ? getChildTemplateCloseState(context) : void 0;
29612
+ const hostsTemplate = node.type === 1 && node.tagType === 0 && !useCreateElement;
29613
+ const childTemplateCloseState = hostsTemplate ? getChildTemplateCloseState(context) : void 0;
29614
+ const childScope = hostsTemplate ? enterOpenScope(context.templateScope, node.tag, node.ns) : 0;
29432
29615
  for (const [i, child] of node.children.entries()) {
29433
29616
  const childContext = context.create(child, i);
29434
- const isInSameTemplate = childTemplateCloseState && child.type === 1 && child.tagType === 0 && isInSameTemplateAsParent(childContext);
29435
- childContext.templateCloseTags = isInSameTemplate ? childTemplateCloseState.tags : void 0;
29436
- childContext.templateCloseBlocks = isInSameTemplate ? childTemplateCloseState.blocks : false;
29617
+ const isInSameTemplate = hostsTemplate && child.type === 1 && child.tagType === 0 && keepsInTemplate(child.tag, child.ns, node.tag, childScope);
29618
+ const closeState = isInSameTemplate ? childTemplateCloseState : void 0;
29619
+ childContext.templateScope = isInSameTemplate ? childScope | 128 : 0;
29620
+ childContext.templateCloseTags = closeState && closeState.tags;
29621
+ childContext.templateCloseBlocks = !!closeState && closeState.blocks;
29437
29622
  transformNode(childContext);
29438
29623
  const childDynamic = childContext.dynamic;
29439
29624
  const createsNode = isFragment || childContext.template !== "" || childDynamic.template != null || childDynamic.id !== void 0 || childDynamic.operation !== void 0 || childDynamic.hasDynamicChild === true;
@@ -29561,7 +29746,7 @@ const transformText = (node, context) => {
29561
29746
  const createElementParent = parent && parent.type === 1 && shouldUseCreateElement(parent, context.parent);
29562
29747
  const isRootText = !parent || parent.type === 0 || parent.type === 1 && (parent.tagType === 3 || parent.tagType === 1);
29563
29748
  const isRawText = createElementParent || isRootText;
29564
- if (isRawText && node.content[0] === "<") {
29749
+ if (needsTextNode(parent, node.content, isRawText)) {
29565
29750
  materializeLiteralTextNode(createSimpleExpression(node.content, true, node.loc), context);
29566
29751
  return;
29567
29752
  }
@@ -29577,7 +29762,7 @@ function processInterpolation(context) {
29577
29762
  const isElementChild = parentNode.type === 1 && parentNode.tagType === 0;
29578
29763
  if (text !== null && parentNode.type !== 0 && (isElementChild || text !== "")) {
29579
29764
  const isRawText = !isElementChild || parentNode.type === 1 && shouldUseCreateElement(parentNode, context.parent);
29580
- if (isRawText && text[0] === "<") {
29765
+ if (needsTextNode(parentNode, text, isRawText)) {
29581
29766
  materializeLiteralTextNode(createSimpleExpression(text, true, context.node.loc), context);
29582
29767
  return;
29583
29768
  }
@@ -29643,6 +29828,16 @@ function registerSyntheticTextChild(context, template, values) {
29643
29828
  function processCreateElementTextContainer(children, context) {
29644
29829
  registerSyntheticTextChild(context, "", processTextLikeChildren(children, context));
29645
29830
  }
29831
+ /**
29832
+ * Text that cannot be written into a template string and is created
29833
+ * imperatively instead: unescaped text starting with "<" (the runtime only
29834
+ * turns a template into a text node when it does not start with "<", see
29835
+ * `template()` in runtime-vapor), and text other than ascii whitespace in a
29836
+ * table part, which the parser would move in front of the table.
29837
+ */
29838
+ function needsTextNode(parent, text, isRawText) {
29839
+ return isRawText && text[0] === "<" || !!parent && parent.type === 1 && parent.ns === 0 && isFosterParentingTag(parent.tag) && !isAllWhitespace(text);
29840
+ }
29646
29841
  function materializeLiteralTextNode(value, context) {
29647
29842
  const id = context.reference();
29648
29843
  context.dynamic.flags |= 6;
@@ -30007,7 +30202,7 @@ function processIf(node, dir, context) {
30007
30202
  const [branch, onExit] = createIfBranch(node, context);
30008
30203
  return () => {
30009
30204
  onExit();
30010
- context.dynamic.operation = _objectSpread2(_objectSpread2({
30205
+ const operation = _objectSpread2(_objectSpread2({
30011
30206
  type: 15,
30012
30207
  id
30013
30208
  }, context.effectBoundary()), {}, {
@@ -30017,6 +30212,8 @@ function processIf(node, dir, context) {
30017
30212
  index: context.root.nextIfIndex(),
30018
30213
  once: context.inVOnce || isStaticExpression(dir.exp, context.options.bindingMetadata)
30019
30214
  });
30215
+ context.dynamic.operation = operation;
30216
+ context.root.ifHeads.set(operation, context.inVOnce);
30020
30217
  };
30021
30218
  } else {
30022
30219
  const siblingIf = getSiblingIf(context, true);
@@ -30033,9 +30230,13 @@ function processIf(node, dir, context) {
30033
30230
  context.options.onError(createCompilerError(30, node.loc));
30034
30231
  return;
30035
30232
  }
30233
+ const head = lastIfNode;
30036
30234
  while (lastIfNode.negative && lastIfNode.negative.type === 15) lastIfNode = lastIfNode.negative;
30235
+ const parent = context.parent;
30236
+ context.inVOnce = parent.inVOnce && !isComponentNode(parent.node) || !!context.root.ifHeads.get(head);
30037
30237
  if (dir.name === "else-if" && lastIfNode.negative) context.options.onError(createCompilerError(30, node.loc));
30038
30238
  checkSameKey(node, context);
30239
+ if (!context.inVOnce) context.node = node = extend({}, node, { props: node.props.filter((prop) => prop.type !== 7 || prop.name !== "once") });
30039
30240
  const comments = context.comment;
30040
30241
  if (comments.length) {
30041
30242
  if (!isInTransition(context)) {
@@ -30240,6 +30441,7 @@ const transformSlotOutlet = (node, context) => {
30240
30441
  function createFallback(node, context) {
30241
30442
  if (!node.children.length) return [];
30242
30443
  context.isSingleRoot = false;
30444
+ context.isSlotRoot = false;
30243
30445
  context.node = node = extend({}, node, {
30244
30446
  type: 1,
30245
30447
  tag: "template",
@@ -30268,11 +30470,11 @@ const transformVSlot = (node, context) => {
30268
30470
  function transformComponentSlot(node, dir, context) {
30269
30471
  const { children } = node;
30270
30472
  const arg = dir && dir.arg;
30271
- const hasTemplateSlots = children.some(isSlotTemplateChild);
30473
+ const hasTemplateSlots = children.some(isSlotTemplate);
30272
30474
  const isTransitionHost = isTransitionHostNode(node);
30273
30475
  const emptyTextNodes = [];
30274
30476
  const nonSlotTemplateChildren = children.filter((n) => {
30275
- if (isSlotTemplateChild(n)) return false;
30477
+ if (isSlotTemplate(n)) return false;
30276
30478
  if (n.type === 3 && (hasTemplateSlots || isTransitionHost)) {
30277
30479
  ignoreComment(n, context);
30278
30480
  return false;
@@ -30396,9 +30598,6 @@ function isNonWhitespaceContent(node) {
30396
30598
  if (node.type !== 2) return true;
30397
30599
  return !!node.content.trim();
30398
30600
  }
30399
- function isSlotTemplateChild(node) {
30400
- return node.type === 1 && isTemplateNode(node) && !!findDir(node, "slot", true);
30401
- }
30402
30601
  //#endregion
30403
30602
  //#region packages/compiler-vapor/src/transforms/transformTransition.ts
30404
30603
  const transformTransition = (node, context) => {
@@ -44342,7 +44541,7 @@ function mergeSourceMaps(scriptMap, templateMap, templateLineOffset) {
44342
44541
  //#endregion
44343
44542
  //#region packages/compiler-sfc/src/index.ts
44344
44543
  init_objectSpread2();
44345
- const version = "3.6.0-rc.12";
44544
+ const version = "3.6.0-rc.13";
44346
44545
  const parseCache = parseCache$1;
44347
44546
  const errorMessages = _objectSpread2(_objectSpread2({}, errorMessages$1), DOMErrorMessages);
44348
44547
  const walk = walk$2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-sfc",
3
- "version": "3.6.0-rc.12",
3
+ "version": "3.6.0-rc.13",
4
4
  "description": "@vue/compiler-sfc",
5
5
  "main": "dist/compiler-sfc.cjs.js",
6
6
  "module": "dist/compiler-sfc.esm-browser.js",
@@ -43,11 +43,11 @@
43
43
  "homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-sfc#readme",
44
44
  "dependencies": {
45
45
  "@babel/parser": "^7.29.9",
46
- "@vue/compiler-core": "3.6.0-rc.12",
47
- "@vue/compiler-dom": "3.6.0-rc.12",
48
- "@vue/compiler-ssr": "3.6.0-rc.12",
49
- "@vue/compiler-vapor": "3.6.0-rc.12",
50
- "@vue/shared": "3.6.0-rc.12",
46
+ "@vue/compiler-core": "3.6.0-rc.13",
47
+ "@vue/compiler-dom": "3.6.0-rc.13",
48
+ "@vue/compiler-ssr": "3.6.0-rc.13",
49
+ "@vue/compiler-vapor": "3.6.0-rc.13",
50
+ "@vue/shared": "3.6.0-rc.13",
51
51
  "estree-walker": "^2.0.2",
52
52
  "magic-string": "^0.30.21",
53
53
  "postcss": "^8.5.29",