@vue/compiler-sfc 3.2.39 → 3.2.40

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.
@@ -4978,7 +4978,7 @@ function processExp(exp, dir) {
4978
4978
  exp = `(${exp})=>{}`;
4979
4979
  }
4980
4980
  else if (dir === 'on') {
4981
- exp = `()=>{${exp}}`;
4981
+ exp = `()=>{return ${exp}}`;
4982
4982
  }
4983
4983
  else if (dir === 'for') {
4984
4984
  const inMatch = exp.match(forAliasRE);
@@ -16568,34 +16568,42 @@ function parseChildren(context, mode, ancestors) {
16568
16568
  const shouldCondense = context.options.whitespace !== 'preserve';
16569
16569
  for (let i = 0; i < nodes.length; i++) {
16570
16570
  const node = nodes[i];
16571
- if (!context.inPre && node.type === 2 /* NodeTypes.TEXT */) {
16572
- if (!/[^\t\r\n\f ]/.test(node.content)) {
16573
- const prev = nodes[i - 1];
16574
- const next = nodes[i + 1];
16575
- // Remove if:
16576
- // - the whitespace is the first or last node, or:
16577
- // - (condense mode) the whitespace is adjacent to a comment, or:
16578
- // - (condense mode) the whitespace is between two elements AND contains newline
16579
- if (!prev ||
16580
- !next ||
16581
- (shouldCondense &&
16582
- (prev.type === 3 /* NodeTypes.COMMENT */ ||
16583
- next.type === 3 /* NodeTypes.COMMENT */ ||
16584
- (prev.type === 1 /* NodeTypes.ELEMENT */ &&
16585
- next.type === 1 /* NodeTypes.ELEMENT */ &&
16586
- /[\r\n]/.test(node.content))))) {
16587
- removedWhitespace = true;
16588
- nodes[i] = null;
16571
+ if (node.type === 2 /* NodeTypes.TEXT */) {
16572
+ if (!context.inPre) {
16573
+ if (!/[^\t\r\n\f ]/.test(node.content)) {
16574
+ const prev = nodes[i - 1];
16575
+ const next = nodes[i + 1];
16576
+ // Remove if:
16577
+ // - the whitespace is the first or last node, or:
16578
+ // - (condense mode) the whitespace is adjacent to a comment, or:
16579
+ // - (condense mode) the whitespace is between two elements AND contains newline
16580
+ if (!prev ||
16581
+ !next ||
16582
+ (shouldCondense &&
16583
+ (prev.type === 3 /* NodeTypes.COMMENT */ ||
16584
+ next.type === 3 /* NodeTypes.COMMENT */ ||
16585
+ (prev.type === 1 /* NodeTypes.ELEMENT */ &&
16586
+ next.type === 1 /* NodeTypes.ELEMENT */ &&
16587
+ /[\r\n]/.test(node.content))))) {
16588
+ removedWhitespace = true;
16589
+ nodes[i] = null;
16590
+ }
16591
+ else {
16592
+ // Otherwise, the whitespace is condensed into a single space
16593
+ node.content = ' ';
16594
+ }
16589
16595
  }
16590
- else {
16591
- // Otherwise, the whitespace is condensed into a single space
16592
- node.content = ' ';
16596
+ else if (shouldCondense) {
16597
+ // in condense mode, consecutive whitespaces in text are condensed
16598
+ // down to a single space.
16599
+ node.content = node.content.replace(/[\t\r\n\f ]+/g, ' ');
16593
16600
  }
16594
16601
  }
16595
- else if (shouldCondense) {
16596
- // in condense mode, consecutive whitespaces in text are condensed
16597
- // down to a single space.
16598
- node.content = node.content.replace(/[\t\r\n\f ]+/g, ' ');
16602
+ else {
16603
+ // #6410 normalize windows newlines in <pre>:
16604
+ // in SSR, browsers normalize server-rendered \r\n into a single \n
16605
+ // in the DOM
16606
+ node.content = node.content.replace(/\r\n/g, '\n');
16599
16607
  }
16600
16608
  }
16601
16609
  // Remove comment nodes if desired by configuration.
@@ -17236,11 +17244,6 @@ function walk(node, context, doNotHoistNode = false) {
17236
17244
  }
17237
17245
  }
17238
17246
  }
17239
- else if (child.type === 12 /* NodeTypes.TEXT_CALL */ &&
17240
- getConstantType(child.content, context) >= 2 /* ConstantTypes.CAN_HOIST */) {
17241
- child.codegenNode = context.hoist(child.codegenNode);
17242
- hoistedCount++;
17243
- }
17244
17247
  // walk further
17245
17248
  if (child.type === 1 /* NodeTypes.ELEMENT */) {
17246
17249
  const isComponent = child.tagType === 1 /* ElementTypes.COMPONENT */;
@@ -23501,6 +23504,14 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
23501
23504
  let hasDynamicKeys = false;
23502
23505
  let hasVnodeHook = false;
23503
23506
  const dynamicPropNames = [];
23507
+ const pushMergeArg = (arg) => {
23508
+ if (properties.length) {
23509
+ mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
23510
+ properties = [];
23511
+ }
23512
+ if (arg)
23513
+ mergeArgs.push(arg);
23514
+ };
23504
23515
  const analyzePatchFlag = ({ key, value }) => {
23505
23516
  if (isStaticExp(key)) {
23506
23517
  const name = key.content;
@@ -23622,16 +23633,14 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
23622
23633
  if (!arg && (isVBind || isVOn)) {
23623
23634
  hasDynamicKeys = true;
23624
23635
  if (exp) {
23625
- if (properties.length) {
23626
- mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
23627
- properties = [];
23628
- }
23629
23636
  if (isVBind) {
23637
+ // have to merge early for compat build check
23638
+ pushMergeArg();
23630
23639
  mergeArgs.push(exp);
23631
23640
  }
23632
23641
  else {
23633
23642
  // v-on="obj" -> toHandlers(obj)
23634
- mergeArgs.push({
23643
+ pushMergeArg({
23635
23644
  type: 14 /* NodeTypes.JS_CALL_EXPRESSION */,
23636
23645
  loc,
23637
23646
  callee: context.helper(TO_HANDLERS),
@@ -23651,7 +23660,12 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
23651
23660
  // has built-in directive transform.
23652
23661
  const { props, needRuntime } = directiveTransform(prop, node, context);
23653
23662
  !ssr && props.forEach(analyzePatchFlag);
23654
- properties.push(...props);
23663
+ if (isVOn && arg && !isStaticExp(arg)) {
23664
+ pushMergeArg(createObjectExpression(props, elementLoc));
23665
+ }
23666
+ else {
23667
+ properties.push(...props);
23668
+ }
23655
23669
  if (needRuntime) {
23656
23670
  runtimeDirectives.push(prop);
23657
23671
  if (isSymbol(needRuntime)) {
@@ -23673,9 +23687,8 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
23673
23687
  let propsExpression = undefined;
23674
23688
  // has v-bind="object" or v-on="object", wrap with mergeProps
23675
23689
  if (mergeArgs.length) {
23676
- if (properties.length) {
23677
- mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
23678
- }
23690
+ // close up any not-yet-merged props
23691
+ pushMergeArg();
23679
23692
  if (mergeArgs.length > 1) {
23680
23693
  propsExpression = createCallExpression(context.helper(MERGE_PROPS), mergeArgs, elementLoc);
23681
23694
  }
@@ -27403,6 +27416,11 @@ function stringifyElement(node, context) {
27403
27416
  res += ` ${p.arg.content}="__VUE_EXP_START__${exp.content}__VUE_EXP_END__"`;
27404
27417
  continue;
27405
27418
  }
27419
+ // #6568
27420
+ if (isBooleanAttr(p.arg.content) &&
27421
+ exp.content === 'false') {
27422
+ continue;
27423
+ }
27406
27424
  // constant v-bind, e.g. :foo="1"
27407
27425
  let evaluated = evaluateConstant(exp);
27408
27426
  if (evaluated != null) {
@@ -34259,7 +34277,10 @@ function ssrCodegenTransform(ast, options) {
34259
34277
  const cssContext = createTransformContext(createRoot([]), options);
34260
34278
  const varsExp = processExpression(createSimpleExpression(options.ssrCssVars, false), cssContext);
34261
34279
  context.body.push(createCompoundExpression([`const _cssVars = { style: `, varsExp, `}`]));
34262
- Array.from(cssContext.helpers.keys()).forEach(helper => ast.helpers.push(helper));
34280
+ Array.from(cssContext.helpers.keys()).forEach(helper => {
34281
+ if (!ast.helpers.includes(helper))
34282
+ ast.helpers.push(helper);
34283
+ });
34263
34284
  }
34264
34285
  const isFragment = ast.children.length > 1 && ast.children.some(c => !isText(c));
34265
34286
  processChildren(ast, context, isFragment);
@@ -37002,7 +37023,7 @@ function processExp(exp, dir) {
37002
37023
  exp = `(${exp})=>{}`;
37003
37024
  }
37004
37025
  else if (dir === 'on') {
37005
- exp = `()=>{${exp}}`;
37026
+ exp = `()=>{return ${exp}}`;
37006
37027
  }
37007
37028
  else if (dir === 'for') {
37008
37029
  const inMatch = exp.match(forAliasRE$1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-sfc",
3
- "version": "3.2.39",
3
+ "version": "3.2.40",
4
4
  "description": "@vue/compiler-sfc",
5
5
  "main": "dist/compiler-sfc.cjs.js",
6
6
  "module": "dist/compiler-sfc.esm-browser.js",
@@ -33,11 +33,11 @@
33
33
  "homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-sfc#readme",
34
34
  "dependencies": {
35
35
  "@babel/parser": "^7.16.4",
36
- "@vue/compiler-core": "3.2.39",
37
- "@vue/compiler-dom": "3.2.39",
38
- "@vue/compiler-ssr": "3.2.39",
39
- "@vue/reactivity-transform": "3.2.39",
40
- "@vue/shared": "3.2.39",
36
+ "@vue/compiler-core": "3.2.40",
37
+ "@vue/compiler-dom": "3.2.40",
38
+ "@vue/compiler-ssr": "3.2.40",
39
+ "@vue/reactivity-transform": "3.2.40",
40
+ "@vue/shared": "3.2.40",
41
41
  "estree-walker": "^2.0.2",
42
42
  "magic-string": "^0.25.7",
43
43
  "source-map": "^0.6.1",