@vue/compiler-core 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.
@@ -972,34 +972,42 @@ function parseChildren(context, mode, ancestors) {
972
972
  const shouldCondense = context.options.whitespace !== 'preserve';
973
973
  for (let i = 0; i < nodes.length; i++) {
974
974
  const node = nodes[i];
975
- if (!context.inPre && node.type === 2 /* NodeTypes.TEXT */) {
976
- if (!/[^\t\r\n\f ]/.test(node.content)) {
977
- const prev = nodes[i - 1];
978
- const next = nodes[i + 1];
979
- // Remove if:
980
- // - the whitespace is the first or last node, or:
981
- // - (condense mode) the whitespace is adjacent to a comment, or:
982
- // - (condense mode) the whitespace is between two elements AND contains newline
983
- if (!prev ||
984
- !next ||
985
- (shouldCondense &&
986
- (prev.type === 3 /* NodeTypes.COMMENT */ ||
987
- next.type === 3 /* NodeTypes.COMMENT */ ||
988
- (prev.type === 1 /* NodeTypes.ELEMENT */ &&
989
- next.type === 1 /* NodeTypes.ELEMENT */ &&
990
- /[\r\n]/.test(node.content))))) {
991
- removedWhitespace = true;
992
- nodes[i] = null;
975
+ if (node.type === 2 /* NodeTypes.TEXT */) {
976
+ if (!context.inPre) {
977
+ if (!/[^\t\r\n\f ]/.test(node.content)) {
978
+ const prev = nodes[i - 1];
979
+ const next = nodes[i + 1];
980
+ // Remove if:
981
+ // - the whitespace is the first or last node, or:
982
+ // - (condense mode) the whitespace is adjacent to a comment, or:
983
+ // - (condense mode) the whitespace is between two elements AND contains newline
984
+ if (!prev ||
985
+ !next ||
986
+ (shouldCondense &&
987
+ (prev.type === 3 /* NodeTypes.COMMENT */ ||
988
+ next.type === 3 /* NodeTypes.COMMENT */ ||
989
+ (prev.type === 1 /* NodeTypes.ELEMENT */ &&
990
+ next.type === 1 /* NodeTypes.ELEMENT */ &&
991
+ /[\r\n]/.test(node.content))))) {
992
+ removedWhitespace = true;
993
+ nodes[i] = null;
994
+ }
995
+ else {
996
+ // Otherwise, the whitespace is condensed into a single space
997
+ node.content = ' ';
998
+ }
993
999
  }
994
- else {
995
- // Otherwise, the whitespace is condensed into a single space
996
- node.content = ' ';
1000
+ else if (shouldCondense) {
1001
+ // in condense mode, consecutive whitespaces in text are condensed
1002
+ // down to a single space.
1003
+ node.content = node.content.replace(/[\t\r\n\f ]+/g, ' ');
997
1004
  }
998
1005
  }
999
- else if (shouldCondense) {
1000
- // in condense mode, consecutive whitespaces in text are condensed
1001
- // down to a single space.
1002
- node.content = node.content.replace(/[\t\r\n\f ]+/g, ' ');
1006
+ else {
1007
+ // #6410 normalize windows newlines in <pre>:
1008
+ // in SSR, browsers normalize server-rendered \r\n into a single \n
1009
+ // in the DOM
1010
+ node.content = node.content.replace(/\r\n/g, '\n');
1003
1011
  }
1004
1012
  }
1005
1013
  // Remove comment nodes if desired by configuration.
@@ -1687,11 +1695,6 @@ function walk(node, context, doNotHoistNode = false) {
1687
1695
  }
1688
1696
  }
1689
1697
  }
1690
- else if (child.type === 12 /* NodeTypes.TEXT_CALL */ &&
1691
- getConstantType(child.content, context) >= 2 /* ConstantTypes.CAN_HOIST */) {
1692
- child.codegenNode = context.hoist(child.codegenNode);
1693
- hoistedCount++;
1694
- }
1695
1698
  // walk further
1696
1699
  if (child.type === 1 /* NodeTypes.ELEMENT */) {
1697
1700
  const isComponent = child.tagType === 1 /* ElementTypes.COMPONENT */;
@@ -4574,6 +4577,14 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4574
4577
  let hasDynamicKeys = false;
4575
4578
  let hasVnodeHook = false;
4576
4579
  const dynamicPropNames = [];
4580
+ const pushMergeArg = (arg) => {
4581
+ if (properties.length) {
4582
+ mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
4583
+ properties = [];
4584
+ }
4585
+ if (arg)
4586
+ mergeArgs.push(arg);
4587
+ };
4577
4588
  const analyzePatchFlag = ({ key, value }) => {
4578
4589
  if (isStaticExp(key)) {
4579
4590
  const name = key.content;
@@ -4695,11 +4706,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4695
4706
  if (!arg && (isVBind || isVOn)) {
4696
4707
  hasDynamicKeys = true;
4697
4708
  if (exp) {
4698
- if (properties.length) {
4699
- mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
4700
- properties = [];
4701
- }
4702
4709
  if (isVBind) {
4710
+ // have to merge early for compat build check
4711
+ pushMergeArg();
4703
4712
  {
4704
4713
  // 2.x v-bind object order compat
4705
4714
  {
@@ -4733,7 +4742,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4733
4742
  }
4734
4743
  else {
4735
4744
  // v-on="obj" -> toHandlers(obj)
4736
- mergeArgs.push({
4745
+ pushMergeArg({
4737
4746
  type: 14 /* NodeTypes.JS_CALL_EXPRESSION */,
4738
4747
  loc,
4739
4748
  callee: context.helper(TO_HANDLERS),
@@ -4753,7 +4762,12 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4753
4762
  // has built-in directive transform.
4754
4763
  const { props, needRuntime } = directiveTransform(prop, node, context);
4755
4764
  !ssr && props.forEach(analyzePatchFlag);
4756
- properties.push(...props);
4765
+ if (isVOn && arg && !isStaticExp(arg)) {
4766
+ pushMergeArg(createObjectExpression(props, elementLoc));
4767
+ }
4768
+ else {
4769
+ properties.push(...props);
4770
+ }
4757
4771
  if (needRuntime) {
4758
4772
  runtimeDirectives.push(prop);
4759
4773
  if (shared.isSymbol(needRuntime)) {
@@ -4775,9 +4789,8 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4775
4789
  let propsExpression = undefined;
4776
4790
  // has v-bind="object" or v-on="object", wrap with mergeProps
4777
4791
  if (mergeArgs.length) {
4778
- if (properties.length) {
4779
- mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
4780
- }
4792
+ // close up any not-yet-merged props
4793
+ pushMergeArg();
4781
4794
  if (mergeArgs.length > 1) {
4782
4795
  propsExpression = createCallExpression(context.helper(MERGE_PROPS), mergeArgs, elementLoc);
4783
4796
  }
@@ -967,34 +967,42 @@ function parseChildren(context, mode, ancestors) {
967
967
  const shouldCondense = context.options.whitespace !== 'preserve';
968
968
  for (let i = 0; i < nodes.length; i++) {
969
969
  const node = nodes[i];
970
- if (!context.inPre && node.type === 2 /* NodeTypes.TEXT */) {
971
- if (!/[^\t\r\n\f ]/.test(node.content)) {
972
- const prev = nodes[i - 1];
973
- const next = nodes[i + 1];
974
- // Remove if:
975
- // - the whitespace is the first or last node, or:
976
- // - (condense mode) the whitespace is adjacent to a comment, or:
977
- // - (condense mode) the whitespace is between two elements AND contains newline
978
- if (!prev ||
979
- !next ||
980
- (shouldCondense &&
981
- (prev.type === 3 /* NodeTypes.COMMENT */ ||
982
- next.type === 3 /* NodeTypes.COMMENT */ ||
983
- (prev.type === 1 /* NodeTypes.ELEMENT */ &&
984
- next.type === 1 /* NodeTypes.ELEMENT */ &&
985
- /[\r\n]/.test(node.content))))) {
986
- removedWhitespace = true;
987
- nodes[i] = null;
970
+ if (node.type === 2 /* NodeTypes.TEXT */) {
971
+ if (!context.inPre) {
972
+ if (!/[^\t\r\n\f ]/.test(node.content)) {
973
+ const prev = nodes[i - 1];
974
+ const next = nodes[i + 1];
975
+ // Remove if:
976
+ // - the whitespace is the first or last node, or:
977
+ // - (condense mode) the whitespace is adjacent to a comment, or:
978
+ // - (condense mode) the whitespace is between two elements AND contains newline
979
+ if (!prev ||
980
+ !next ||
981
+ (shouldCondense &&
982
+ (prev.type === 3 /* NodeTypes.COMMENT */ ||
983
+ next.type === 3 /* NodeTypes.COMMENT */ ||
984
+ (prev.type === 1 /* NodeTypes.ELEMENT */ &&
985
+ next.type === 1 /* NodeTypes.ELEMENT */ &&
986
+ /[\r\n]/.test(node.content))))) {
987
+ removedWhitespace = true;
988
+ nodes[i] = null;
989
+ }
990
+ else {
991
+ // Otherwise, the whitespace is condensed into a single space
992
+ node.content = ' ';
993
+ }
988
994
  }
989
- else {
990
- // Otherwise, the whitespace is condensed into a single space
991
- node.content = ' ';
995
+ else if (shouldCondense) {
996
+ // in condense mode, consecutive whitespaces in text are condensed
997
+ // down to a single space.
998
+ node.content = node.content.replace(/[\t\r\n\f ]+/g, ' ');
992
999
  }
993
1000
  }
994
- else if (shouldCondense) {
995
- // in condense mode, consecutive whitespaces in text are condensed
996
- // down to a single space.
997
- node.content = node.content.replace(/[\t\r\n\f ]+/g, ' ');
1001
+ else {
1002
+ // #6410 normalize windows newlines in <pre>:
1003
+ // in SSR, browsers normalize server-rendered \r\n into a single \n
1004
+ // in the DOM
1005
+ node.content = node.content.replace(/\r\n/g, '\n');
998
1006
  }
999
1007
  }
1000
1008
  // Remove comment nodes if desired by configuration.
@@ -1659,11 +1667,6 @@ function walk(node, context, doNotHoistNode = false) {
1659
1667
  }
1660
1668
  }
1661
1669
  }
1662
- else if (child.type === 12 /* NodeTypes.TEXT_CALL */ &&
1663
- getConstantType(child.content, context) >= 2 /* ConstantTypes.CAN_HOIST */) {
1664
- child.codegenNode = context.hoist(child.codegenNode);
1665
- hoistedCount++;
1666
- }
1667
1670
  // walk further
1668
1671
  if (child.type === 1 /* NodeTypes.ELEMENT */) {
1669
1672
  const isComponent = child.tagType === 1 /* ElementTypes.COMPONENT */;
@@ -4471,6 +4474,14 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4471
4474
  let hasDynamicKeys = false;
4472
4475
  let hasVnodeHook = false;
4473
4476
  const dynamicPropNames = [];
4477
+ const pushMergeArg = (arg) => {
4478
+ if (properties.length) {
4479
+ mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
4480
+ properties = [];
4481
+ }
4482
+ if (arg)
4483
+ mergeArgs.push(arg);
4484
+ };
4474
4485
  const analyzePatchFlag = ({ key, value }) => {
4475
4486
  if (isStaticExp(key)) {
4476
4487
  const name = key.content;
@@ -4592,11 +4603,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4592
4603
  if (!arg && (isVBind || isVOn)) {
4593
4604
  hasDynamicKeys = true;
4594
4605
  if (exp) {
4595
- if (properties.length) {
4596
- mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
4597
- properties = [];
4598
- }
4599
4606
  if (isVBind) {
4607
+ // have to merge early for compat build check
4608
+ pushMergeArg();
4600
4609
  {
4601
4610
  if (isCompatEnabled("COMPILER_V_BIND_OBJECT_ORDER" /* CompilerDeprecationTypes.COMPILER_V_BIND_OBJECT_ORDER */, context)) {
4602
4611
  mergeArgs.unshift(exp);
@@ -4607,7 +4616,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4607
4616
  }
4608
4617
  else {
4609
4618
  // v-on="obj" -> toHandlers(obj)
4610
- mergeArgs.push({
4619
+ pushMergeArg({
4611
4620
  type: 14 /* NodeTypes.JS_CALL_EXPRESSION */,
4612
4621
  loc,
4613
4622
  callee: context.helper(TO_HANDLERS),
@@ -4627,7 +4636,12 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4627
4636
  // has built-in directive transform.
4628
4637
  const { props, needRuntime } = directiveTransform(prop, node, context);
4629
4638
  !ssr && props.forEach(analyzePatchFlag);
4630
- properties.push(...props);
4639
+ if (isVOn && arg && !isStaticExp(arg)) {
4640
+ pushMergeArg(createObjectExpression(props, elementLoc));
4641
+ }
4642
+ else {
4643
+ properties.push(...props);
4644
+ }
4631
4645
  if (needRuntime) {
4632
4646
  runtimeDirectives.push(prop);
4633
4647
  if (shared.isSymbol(needRuntime)) {
@@ -4649,9 +4663,8 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4649
4663
  let propsExpression = undefined;
4650
4664
  // has v-bind="object" or v-on="object", wrap with mergeProps
4651
4665
  if (mergeArgs.length) {
4652
- if (properties.length) {
4653
- mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
4654
- }
4666
+ // close up any not-yet-merged props
4667
+ pushMergeArg();
4655
4668
  if (mergeArgs.length > 1) {
4656
4669
  propsExpression = createCallExpression(context.helper(MERGE_PROPS), mergeArgs, elementLoc);
4657
4670
  }
@@ -956,34 +956,42 @@ function parseChildren(context, mode, ancestors) {
956
956
  const shouldCondense = context.options.whitespace !== 'preserve';
957
957
  for (let i = 0; i < nodes.length; i++) {
958
958
  const node = nodes[i];
959
- if (!context.inPre && node.type === 2 /* NodeTypes.TEXT */) {
960
- if (!/[^\t\r\n\f ]/.test(node.content)) {
961
- const prev = nodes[i - 1];
962
- const next = nodes[i + 1];
963
- // Remove if:
964
- // - the whitespace is the first or last node, or:
965
- // - (condense mode) the whitespace is adjacent to a comment, or:
966
- // - (condense mode) the whitespace is between two elements AND contains newline
967
- if (!prev ||
968
- !next ||
969
- (shouldCondense &&
970
- (prev.type === 3 /* NodeTypes.COMMENT */ ||
971
- next.type === 3 /* NodeTypes.COMMENT */ ||
972
- (prev.type === 1 /* NodeTypes.ELEMENT */ &&
973
- next.type === 1 /* NodeTypes.ELEMENT */ &&
974
- /[\r\n]/.test(node.content))))) {
975
- removedWhitespace = true;
976
- nodes[i] = null;
959
+ if (node.type === 2 /* NodeTypes.TEXT */) {
960
+ if (!context.inPre) {
961
+ if (!/[^\t\r\n\f ]/.test(node.content)) {
962
+ const prev = nodes[i - 1];
963
+ const next = nodes[i + 1];
964
+ // Remove if:
965
+ // - the whitespace is the first or last node, or:
966
+ // - (condense mode) the whitespace is adjacent to a comment, or:
967
+ // - (condense mode) the whitespace is between two elements AND contains newline
968
+ if (!prev ||
969
+ !next ||
970
+ (shouldCondense &&
971
+ (prev.type === 3 /* NodeTypes.COMMENT */ ||
972
+ next.type === 3 /* NodeTypes.COMMENT */ ||
973
+ (prev.type === 1 /* NodeTypes.ELEMENT */ &&
974
+ next.type === 1 /* NodeTypes.ELEMENT */ &&
975
+ /[\r\n]/.test(node.content))))) {
976
+ removedWhitespace = true;
977
+ nodes[i] = null;
978
+ }
979
+ else {
980
+ // Otherwise, the whitespace is condensed into a single space
981
+ node.content = ' ';
982
+ }
977
983
  }
978
- else {
979
- // Otherwise, the whitespace is condensed into a single space
980
- node.content = ' ';
984
+ else if (shouldCondense) {
985
+ // in condense mode, consecutive whitespaces in text are condensed
986
+ // down to a single space.
987
+ node.content = node.content.replace(/[\t\r\n\f ]+/g, ' ');
981
988
  }
982
989
  }
983
- else if (shouldCondense) {
984
- // in condense mode, consecutive whitespaces in text are condensed
985
- // down to a single space.
986
- node.content = node.content.replace(/[\t\r\n\f ]+/g, ' ');
990
+ else {
991
+ // #6410 normalize windows newlines in <pre>:
992
+ // in SSR, browsers normalize server-rendered \r\n into a single \n
993
+ // in the DOM
994
+ node.content = node.content.replace(/\r\n/g, '\n');
987
995
  }
988
996
  }
989
997
  // Remove comment nodes if desired by configuration.
@@ -1672,11 +1680,6 @@ function walk(node, context, doNotHoistNode = false) {
1672
1680
  }
1673
1681
  }
1674
1682
  }
1675
- else if (child.type === 12 /* NodeTypes.TEXT_CALL */ &&
1676
- getConstantType(child.content, context) >= 2 /* ConstantTypes.CAN_HOIST */) {
1677
- child.codegenNode = context.hoist(child.codegenNode);
1678
- hoistedCount++;
1679
- }
1680
1683
  // walk further
1681
1684
  if (child.type === 1 /* NodeTypes.ELEMENT */) {
1682
1685
  const isComponent = child.tagType === 1 /* ElementTypes.COMPONENT */;
@@ -3835,6 +3838,14 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
3835
3838
  let hasDynamicKeys = false;
3836
3839
  let hasVnodeHook = false;
3837
3840
  const dynamicPropNames = [];
3841
+ const pushMergeArg = (arg) => {
3842
+ if (properties.length) {
3843
+ mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
3844
+ properties = [];
3845
+ }
3846
+ if (arg)
3847
+ mergeArgs.push(arg);
3848
+ };
3838
3849
  const analyzePatchFlag = ({ key, value }) => {
3839
3850
  if (isStaticExp(key)) {
3840
3851
  const name = key.content;
@@ -3947,11 +3958,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
3947
3958
  if (!arg && (isVBind || isVOn)) {
3948
3959
  hasDynamicKeys = true;
3949
3960
  if (exp) {
3950
- if (properties.length) {
3951
- mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
3952
- properties = [];
3953
- }
3954
3961
  if (isVBind) {
3962
+ // have to merge early for compat build check
3963
+ pushMergeArg();
3955
3964
  {
3956
3965
  // 2.x v-bind object order compat
3957
3966
  if ((process.env.NODE_ENV !== 'production')) {
@@ -3985,7 +3994,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
3985
3994
  }
3986
3995
  else {
3987
3996
  // v-on="obj" -> toHandlers(obj)
3988
- mergeArgs.push({
3997
+ pushMergeArg({
3989
3998
  type: 14 /* NodeTypes.JS_CALL_EXPRESSION */,
3990
3999
  loc,
3991
4000
  callee: context.helper(TO_HANDLERS),
@@ -4005,7 +4014,12 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4005
4014
  // has built-in directive transform.
4006
4015
  const { props, needRuntime } = directiveTransform(prop, node, context);
4007
4016
  !ssr && props.forEach(analyzePatchFlag);
4008
- properties.push(...props);
4017
+ if (isVOn && arg && !isStaticExp(arg)) {
4018
+ pushMergeArg(createObjectExpression(props, elementLoc));
4019
+ }
4020
+ else {
4021
+ properties.push(...props);
4022
+ }
4009
4023
  if (needRuntime) {
4010
4024
  runtimeDirectives.push(prop);
4011
4025
  if (isSymbol(needRuntime)) {
@@ -4027,9 +4041,8 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4027
4041
  let propsExpression = undefined;
4028
4042
  // has v-bind="object" or v-on="object", wrap with mergeProps
4029
4043
  if (mergeArgs.length) {
4030
- if (properties.length) {
4031
- mergeArgs.push(createObjectExpression(dedupeProperties(properties), elementLoc));
4032
- }
4044
+ // close up any not-yet-merged props
4045
+ pushMergeArg();
4033
4046
  if (mergeArgs.length > 1) {
4034
4047
  propsExpression = createCallExpression(context.helper(MERGE_PROPS), mergeArgs, elementLoc);
4035
4048
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-core",
3
- "version": "3.2.39",
3
+ "version": "3.2.40",
4
4
  "description": "@vue/compiler-core",
5
5
  "main": "index.js",
6
6
  "module": "dist/compiler-core.esm-bundler.js",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-core#readme",
34
34
  "dependencies": {
35
- "@vue/shared": "3.2.39",
35
+ "@vue/shared": "3.2.40",
36
36
  "@babel/parser": "^7.16.4",
37
37
  "estree-walker": "^2.0.2",
38
38
  "source-map": "^0.6.1"