@vue/compiler-sfc 3.6.0-beta.1 → 3.6.0-beta.2

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-beta.1
2
+ * @vue/compiler-sfc v3.6.0-beta.2
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -21523,7 +21523,8 @@ let __temp${any}, __restore${any}
21523
21523
  if (preamble) {
21524
21524
  ctx.s.prepend(preamble);
21525
21525
  }
21526
- if (helpers && helpers.has(CompilerDOM.UNREF)) {
21526
+ if (helpers && (helpers.has(CompilerDOM.UNREF) || // vapor compiler uses 'unref' instead of UNREF
21527
+ helpers.has("unref"))) {
21527
21528
  ctx.helperImports.delete("unref");
21528
21529
  }
21529
21530
  returned = code;
@@ -21816,7 +21817,7 @@ function mergeSourceMaps(scriptMap, templateMap, templateLineOffset) {
21816
21817
  return generator.toJSON();
21817
21818
  }
21818
21819
 
21819
- const version = "3.6.0-beta.1";
21820
+ const version = "3.6.0-beta.2";
21820
21821
  const parseCache = parseCache$1;
21821
21822
  const errorMessages = {
21822
21823
  ...CompilerDOM.errorMessages,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-sfc v3.6.0-beta.1
2
+ * @vue/compiler-sfc v3.6.0-beta.2
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -221,10 +221,12 @@ const HTML_TAGS = "html,body,base,head,link,meta,style,title,address,article,asi
221
221
  const SVG_TAGS = "svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,text,textPath,title,tspan,unknown,use,view";
222
222
  const MATH_TAGS = "annotation,annotation-xml,maction,maligngroup,malignmark,math,menclose,merror,mfenced,mfrac,mfraction,mglyph,mi,mlabeledtr,mlongdiv,mmultiscripts,mn,mo,mover,mpadded,mphantom,mprescripts,mroot,mrow,ms,mscarries,mscarry,msgroup,msline,mspace,msqrt,msrow,mstack,mstyle,msub,msubsup,msup,mtable,mtd,mtext,mtr,munder,munderover,none,semantics";
223
223
  const VOID_TAGS = "area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr";
224
+ const FORMATTING_TAGS = "a,b,big,code,em,font,i,nobr,s,small,strike,strong,tt,u";
224
225
  const isHTMLTag = /* @__PURE__ */ makeMap(HTML_TAGS);
225
226
  const isSVGTag = /* @__PURE__ */ makeMap(SVG_TAGS);
226
227
  const isMathMLTag = /* @__PURE__ */ makeMap(MATH_TAGS);
227
228
  const isVoidTag = /* @__PURE__ */ makeMap(VOID_TAGS);
229
+ const isFormattingTag = /* @__PURE__ */ makeMap(FORMATTING_TAGS);
228
230
 
229
231
  const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
230
232
  const isBooleanAttr = /* @__PURE__ */ makeMap(
@@ -19443,8 +19445,7 @@ function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [
19443
19445
  if (includeAll || isRefed && !isLocal) {
19444
19446
  onIdentifier(node, parent, parentStack, isRefed, isLocal);
19445
19447
  }
19446
- } else if (node.type === "ObjectProperty" && // eslint-disable-next-line no-restricted-syntax
19447
- (parent == null ? void 0 : parent.type) === "ObjectPattern") {
19448
+ } else if (node.type === "ObjectProperty" && (parent == null ? void 0 : parent.type) === "ObjectPattern") {
19448
19449
  node.inPattern = true;
19449
19450
  } else if (isFunctionType(node)) {
19450
19451
  if (node.scopeIds) {
@@ -32321,6 +32322,8 @@ class TransformContext {
32321
32322
  this.node = node;
32322
32323
  this.selfName = null;
32323
32324
  this.parent = null;
32325
+ // cached parent that skips template tags
32326
+ this.effectiveParent = null;
32324
32327
  this.index = 0;
32325
32328
  this.block = this.ir.block;
32326
32329
  this.template = "";
@@ -32333,6 +32336,12 @@ class TransformContext {
32333
32336
  this.component = this.ir.component;
32334
32337
  this.directive = this.ir.directive;
32335
32338
  this.slots = [];
32339
+ // whether this node is the last effective child of its parent
32340
+ // (all siblings after it are components, which don't appear in HTML template)
32341
+ this.isLastEffectiveChild = true;
32342
+ // whether this node is on the rightmost path of the tree
32343
+ // (all ancestors are also last effective children)
32344
+ this.isOnRightmostPath = true;
32336
32345
  this.globalId = 0;
32337
32346
  this.nextIdMap = null;
32338
32347
  this.increaseId = () => {
@@ -32413,15 +32422,31 @@ class TransformContext {
32413
32422
  this.block.operation.push(...node);
32414
32423
  }
32415
32424
  create(node, index) {
32425
+ let effectiveParent = this;
32426
+ while (effectiveParent && effectiveParent.node.type === 1 && effectiveParent.node.tagType === 3) {
32427
+ effectiveParent = effectiveParent.parent;
32428
+ }
32429
+ const isLastEffectiveChild = this.isEffectivelyLastChild(index);
32430
+ const isOnRightmostPath = this.isOnRightmostPath && isLastEffectiveChild;
32416
32431
  return Object.assign(Object.create(TransformContext.prototype), this, {
32417
32432
  node,
32418
32433
  parent: this,
32419
32434
  index,
32420
32435
  template: "",
32421
32436
  childrenTemplate: [],
32422
- dynamic: newDynamic()
32437
+ dynamic: newDynamic(),
32438
+ effectiveParent,
32439
+ isLastEffectiveChild,
32440
+ isOnRightmostPath
32423
32441
  });
32424
32442
  }
32443
+ isEffectivelyLastChild(index) {
32444
+ const children = this.node.children;
32445
+ if (!children) return true;
32446
+ return children.every(
32447
+ (c, i) => i <= index || c.type === 1 && c.tagType === 1
32448
+ );
32449
+ }
32425
32450
  }
32426
32451
  const defaultOptions = {
32427
32452
  filename: "",
@@ -32961,6 +32986,10 @@ function analyzeExpressions(expressions) {
32961
32986
  end: id.end
32962
32987
  });
32963
32988
  });
32989
+ const parentOfMemberExp = parentStack[parentStack.length - 2];
32990
+ if (parentOfMemberExp && isCallExpression(parentOfMemberExp)) {
32991
+ return;
32992
+ }
32964
32993
  registerVariable(
32965
32994
  memberExp,
32966
32995
  exp,
@@ -33177,6 +33206,8 @@ function extractMemberExpression(exp, onIdentifier) {
33177
33206
  return `${extractMemberExpression(exp.left, onIdentifier)} ${exp.operator} ${extractMemberExpression(exp.right, onIdentifier)}`;
33178
33207
  case "CallExpression":
33179
33208
  return `${extractMemberExpression(exp.callee, onIdentifier)}(${exp.arguments.map((arg) => extractMemberExpression(arg, onIdentifier)).join(", ")})`;
33209
+ case "OptionalCallExpression":
33210
+ return `${extractMemberExpression(exp.callee, onIdentifier)}?.(${exp.arguments.map((arg) => extractMemberExpression(arg, onIdentifier)).join(", ")})`;
33180
33211
  case "MemberExpression":
33181
33212
  // foo[bar.baz]
33182
33213
  case "OptionalMemberExpression":
@@ -33189,6 +33220,9 @@ function extractMemberExpression(exp, onIdentifier) {
33189
33220
  return "";
33190
33221
  }
33191
33222
  }
33223
+ const isCallExpression = (node) => {
33224
+ return node.type === "CallExpression" || node.type === "OptionalCallExpression";
33225
+ };
33192
33226
  const isMemberExpression = (node) => {
33193
33227
  return node.type === "MemberExpression" || node.type === "OptionalMemberExpression" || node.type === "TSNonNullExpression";
33194
33228
  };
@@ -35168,7 +35202,10 @@ const transformElement = (node, context) => {
35168
35202
  propsResult,
35169
35203
  singleRoot,
35170
35204
  context,
35171
- getEffectIndex
35205
+ getEffectIndex,
35206
+ // Root-level elements generate dedicated templates
35207
+ // so closing tags can be omitted
35208
+ context.root === context.effectiveParent || canOmitEndTag(node, context)
35172
35209
  );
35173
35210
  }
35174
35211
  if (parentSlots) {
@@ -35176,6 +35213,17 @@ const transformElement = (node, context) => {
35176
35213
  }
35177
35214
  };
35178
35215
  };
35216
+ function canOmitEndTag(node, context) {
35217
+ const { block, parent } = context;
35218
+ if (!parent) return false;
35219
+ if (block !== parent.block) {
35220
+ return true;
35221
+ }
35222
+ if (isFormattingTag(node.tag) || parent.node.type === 1 && node.tag === parent.node.tag) {
35223
+ return context.isOnRightmostPath;
35224
+ }
35225
+ return context.isLastEffectiveChild;
35226
+ }
35179
35227
  function isSingleRoot(context) {
35180
35228
  if (context.inVFor) {
35181
35229
  return false;
@@ -35265,7 +35313,8 @@ function resolveSetupReference(name, context) {
35265
35313
  return bindings[name] ? name : bindings[camelName] ? camelName : bindings[PascalName] ? PascalName : void 0;
35266
35314
  }
35267
35315
  const dynamicKeys = ["indeterminate"];
35268
- function transformNativeElement(node, propsResult, singleRoot, context, getEffectIndex) {
35316
+ const NEEDS_QUOTES_RE = /[\s"'`=<>]/;
35317
+ function transformNativeElement(node, propsResult, singleRoot, context, getEffectIndex, omitEndTag) {
35269
35318
  const { tag } = node;
35270
35319
  const { scopeId } = context.options;
35271
35320
  let template = "";
@@ -35285,16 +35334,24 @@ function transformNativeElement(node, propsResult, singleRoot, context, getEffec
35285
35334
  getEffectIndex
35286
35335
  );
35287
35336
  } else {
35337
+ let prevWasQuoted = false;
35288
35338
  for (const prop of propsResult[1]) {
35289
35339
  const { key, values } = prop;
35290
35340
  if (context.imports.some(
35291
35341
  (imported) => values[0].content.includes(imported.exp.content)
35292
35342
  )) {
35293
- template += ` ${key.content}="${IMPORT_EXP_START}${values[0].content}${IMPORT_EXP_END}"`;
35343
+ if (!prevWasQuoted) template += ` `;
35344
+ template += `${key.content}="${IMPORT_EXP_START}${values[0].content}${IMPORT_EXP_END}"`;
35345
+ prevWasQuoted = true;
35294
35346
  } else if (key.isStatic && values.length === 1 && (values[0].isStatic || values[0].content === "''") && !dynamicKeys.includes(key.content)) {
35295
- template += ` ${key.content}`;
35296
- if (values[0].content)
35297
- template += `="${values[0].content === "''" ? "" : values[0].content}"`;
35347
+ if (!prevWasQuoted) template += ` `;
35348
+ const value = values[0].content === "''" ? "" : values[0].content;
35349
+ template += key.content;
35350
+ if (value) {
35351
+ template += (prevWasQuoted = NEEDS_QUOTES_RE.test(value)) ? `="${value.replace(/"/g, "&quot;")}"` : `=${value}`;
35352
+ } else {
35353
+ prevWasQuoted = false;
35354
+ }
35298
35355
  } else {
35299
35356
  dynamicProps.push(key.content);
35300
35357
  context.registerEffect(
@@ -35311,7 +35368,7 @@ function transformNativeElement(node, propsResult, singleRoot, context, getEffec
35311
35368
  }
35312
35369
  }
35313
35370
  template += `>` + context.childrenTemplate.join("");
35314
- if (!isVoidTag(tag)) {
35371
+ if (!isVoidTag(tag) && !omitEndTag) {
35315
35372
  template += `</${tag}>`;
35316
35373
  }
35317
35374
  if (singleRoot) {
@@ -55036,7 +55093,8 @@ let __temp${any}, __restore${any}
55036
55093
  if (preamble) {
55037
55094
  ctx.s.prepend(preamble);
55038
55095
  }
55039
- if (helpers && helpers.has(UNREF)) {
55096
+ if (helpers && (helpers.has(UNREF) || // vapor compiler uses 'unref' instead of UNREF
55097
+ helpers.has("unref"))) {
55040
55098
  ctx.helperImports.delete("unref");
55041
55099
  }
55042
55100
  returned = code;
@@ -55344,7 +55402,7 @@ var __spreadValues = (a, b) => {
55344
55402
  }
55345
55403
  return a;
55346
55404
  };
55347
- const version = "3.6.0-beta.1";
55405
+ const version = "3.6.0-beta.2";
55348
55406
  const parseCache = parseCache$1;
55349
55407
  const errorMessages = __spreadValues(__spreadValues({}, errorMessages$1), DOMErrorMessages);
55350
55408
  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-beta.1",
3
+ "version": "3.6.0-beta.2",
4
4
  "description": "@vue/compiler-sfc",
5
5
  "main": "dist/compiler-sfc.cjs.js",
6
6
  "module": "dist/compiler-sfc.esm-browser.js",
@@ -47,11 +47,11 @@
47
47
  "magic-string": "^0.30.21",
48
48
  "postcss": "^8.5.6",
49
49
  "source-map-js": "^1.2.1",
50
- "@vue/compiler-core": "3.6.0-beta.1",
51
- "@vue/compiler-dom": "3.6.0-beta.1",
52
- "@vue/compiler-ssr": "3.6.0-beta.1",
53
- "@vue/compiler-vapor": "3.6.0-beta.1",
54
- "@vue/shared": "3.6.0-beta.1"
50
+ "@vue/compiler-dom": "3.6.0-beta.2",
51
+ "@vue/compiler-core": "3.6.0-beta.2",
52
+ "@vue/compiler-ssr": "3.6.0-beta.2",
53
+ "@vue/shared": "3.6.0-beta.2",
54
+ "@vue/compiler-vapor": "3.6.0-beta.2"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@babel/types": "^7.28.5",