@vue/compiler-dom 3.6.0-alpha.4 → 3.6.0-alpha.5

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,9 +1,9 @@
1
1
  /**
2
- * @vue/compiler-dom v3.6.0-alpha.4
2
+ * @vue/compiler-dom v3.6.0-alpha.5
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
6
- import { registerRuntimeHelpers, createSimpleExpression, createCompilerError, createObjectProperty, createCallExpression, getConstantType, TO_DISPLAY_STRING, transformModel as transformModel$1, findProp, hasDynamicKeyVBind, findDir, isStaticArgOf, transformOn as transformOn$1, isStaticExp, createCompoundExpression, checkCompatEnabled, noopDirectiveTransform, baseCompile, baseParse } from '@vue/compiler-core';
6
+ import { registerRuntimeHelpers, createSimpleExpression, createCompilerError, createObjectProperty, createCallExpression, getConstantType, TO_DISPLAY_STRING, transformModel as transformModel$1, findProp, hasDynamicKeyVBind, findDir, isStaticArgOf, transformOn as transformOn$1, isStaticExp, createCompoundExpression, checkCompatEnabled, isCommentOrWhitespace, noopDirectiveTransform, baseCompile, baseParse } from '@vue/compiler-core';
7
7
  export * from '@vue/compiler-core';
8
8
  import { isHTMLTag, isSVGTag, isMathMLTag, isVoidTag, parseStringStyle, makeMap, capitalize, isString, extend } from '@vue/shared';
9
9
 
@@ -458,7 +458,7 @@ function postTransformTransition(node, onError, hasMultipleChildren = defaultHas
458
458
  }
459
459
  function defaultHasMultipleChildren(node) {
460
460
  const children = node.children = node.children.filter(
461
- (c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
461
+ (c) => !isCommentOrWhitespace(c)
462
462
  );
463
463
  const child = children[0];
464
464
  return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(defaultHasMultipleChildren);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-dom v3.6.0-alpha.4
2
+ * @vue/compiler-dom v3.6.0-alpha.5
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -2104,7 +2104,43 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
2104
2104
  return node;
2105
2105
  }
2106
2106
  }
2107
+ function filterNonCommentChildren(node) {
2108
+ return node.children.filter((n) => n.type !== 3);
2109
+ }
2110
+ function hasSingleChild(node) {
2111
+ return filterNonCommentChildren(node).length === 1;
2112
+ }
2113
+ function isSingleIfBlock(parent) {
2114
+ let hasEncounteredIf = false;
2115
+ for (const c of filterNonCommentChildren(parent)) {
2116
+ if (c.type === 9 || c.type === 1 && findDir(c, "if")) {
2117
+ if (hasEncounteredIf) return false;
2118
+ hasEncounteredIf = true;
2119
+ } else if (
2120
+ // node before v-if
2121
+ !hasEncounteredIf || // non else nodes
2122
+ !(c.type === 1 && findDir(c, /^else(-if)?$/, true))
2123
+ ) {
2124
+ return false;
2125
+ }
2126
+ }
2127
+ return true;
2128
+ }
2107
2129
  const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+(\S[\s\S]*)/;
2130
+ function isAllWhitespace(str) {
2131
+ for (let i = 0; i < str.length; i++) {
2132
+ if (!isWhitespace(str.charCodeAt(i))) {
2133
+ return false;
2134
+ }
2135
+ }
2136
+ return true;
2137
+ }
2138
+ function isWhitespaceText(node) {
2139
+ return node.type === 2 && isAllWhitespace(node.content) || node.type === 12 && isWhitespaceText(node.content);
2140
+ }
2141
+ function isCommentOrWhitespace(node) {
2142
+ return node.type === 3 || isWhitespaceText(node);
2143
+ }
2108
2144
 
2109
2145
  const defaultParserOptions = {
2110
2146
  parseMode: "base",
@@ -2727,14 +2763,6 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
2727
2763
  }
2728
2764
  return removedWhitespace ? nodes.filter(Boolean) : nodes;
2729
2765
  }
2730
- function isAllWhitespace(str) {
2731
- for (let i = 0; i < str.length; i++) {
2732
- if (!isWhitespace(str.charCodeAt(i))) {
2733
- return false;
2734
- }
2735
- }
2736
- return true;
2737
- }
2738
2766
  function hasNewlineChar(str) {
2739
2767
  for (let i = 0; i < str.length; i++) {
2740
2768
  const c = str.charCodeAt(i);
@@ -4178,13 +4206,11 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
4178
4206
  let i = siblings.indexOf(node);
4179
4207
  while (i-- >= -1) {
4180
4208
  const sibling = siblings[i];
4181
- if (sibling && sibling.type === 3) {
4182
- context.removeNode(sibling);
4183
- comments.unshift(sibling);
4184
- continue;
4185
- }
4186
- if (sibling && sibling.type === 2 && !sibling.content.trim().length) {
4209
+ if (sibling && isCommentOrWhitespace(sibling)) {
4187
4210
  context.removeNode(sibling);
4211
+ if (sibling.type === 3) {
4212
+ comments.unshift(sibling);
4213
+ }
4188
4214
  continue;
4189
4215
  }
4190
4216
  if (sibling && sibling.type === 9) {
@@ -4656,7 +4682,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
4656
4682
  let prev;
4657
4683
  while (j--) {
4658
4684
  prev = children[j];
4659
- if (prev.type !== 3 && isNonWhitespaceContent(prev)) {
4685
+ if (!isCommentOrWhitespace(prev)) {
4660
4686
  break;
4661
4687
  }
4662
4688
  }
@@ -4734,7 +4760,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
4734
4760
  } else if (implicitDefaultChildren.length && // #3766
4735
4761
  // with whitespace: 'preserve', whitespaces between slots will end up in
4736
4762
  // implicitDefaultChildren. Ignore if all implicit children are whitespaces.
4737
- implicitDefaultChildren.some((node2) => isNonWhitespaceContent(node2))) {
4763
+ !implicitDefaultChildren.every(isWhitespaceText)) {
4738
4764
  if (hasNamedDefaultSlot) {
4739
4765
  context.onError(
4740
4766
  createCompilerError(
@@ -4807,11 +4833,6 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
4807
4833
  }
4808
4834
  return false;
4809
4835
  }
4810
- function isNonWhitespaceContent(node) {
4811
- if (node.type !== 2 && node.type !== 12)
4812
- return true;
4813
- return node.type === 2 ? !!node.content.trim() : isNonWhitespaceContent(node.content);
4814
- }
4815
4836
 
4816
4837
  const directiveImportMap = /* @__PURE__ */ new WeakMap();
4817
4838
  const transformElement = (node, context) => {
@@ -6457,7 +6478,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
6457
6478
  }
6458
6479
  function defaultHasMultipleChildren(node) {
6459
6480
  const children = node.children = node.children.filter(
6460
- (c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
6481
+ (c) => !isCommentOrWhitespace(c)
6461
6482
  );
6462
6483
  const child = children[0];
6463
6484
  return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(defaultHasMultipleChildren);
@@ -6788,6 +6809,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
6788
6809
  exports.defaultOnWarn = defaultOnWarn;
6789
6810
  exports.errorMessages = errorMessages;
6790
6811
  exports.extractIdentifiers = extractIdentifiers;
6812
+ exports.filterNonCommentChildren = filterNonCommentChildren;
6791
6813
  exports.findDir = findDir;
6792
6814
  exports.findProp = findProp;
6793
6815
  exports.forAliasRE = forAliasRE;
@@ -6801,8 +6823,11 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
6801
6823
  exports.getVNodeHelper = getVNodeHelper;
6802
6824
  exports.hasDynamicKeyVBind = hasDynamicKeyVBind;
6803
6825
  exports.hasScopeRef = hasScopeRef;
6826
+ exports.hasSingleChild = hasSingleChild;
6804
6827
  exports.helperNameMap = helperNameMap;
6805
6828
  exports.injectProp = injectProp;
6829
+ exports.isAllWhitespace = isAllWhitespace;
6830
+ exports.isCommentOrWhitespace = isCommentOrWhitespace;
6806
6831
  exports.isConstantNode = isConstantNode;
6807
6832
  exports.isCoreComponent = isCoreComponent;
6808
6833
  exports.isFnExpression = isFnExpression;
@@ -6817,6 +6842,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
6817
6842
  exports.isMemberExpressionNode = isMemberExpressionNode;
6818
6843
  exports.isReferencedIdentifier = isReferencedIdentifier;
6819
6844
  exports.isSimpleIdentifier = isSimpleIdentifier;
6845
+ exports.isSingleIfBlock = isSingleIfBlock;
6820
6846
  exports.isSlotOutlet = isSlotOutlet;
6821
6847
  exports.isStaticArgOf = isStaticArgOf;
6822
6848
  exports.isStaticExp = isStaticExp;
@@ -6828,6 +6854,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
6828
6854
  exports.isVPre = isVPre;
6829
6855
  exports.isVSlot = isVSlot;
6830
6856
  exports.isValidHTMLNesting = isValidHTMLNesting;
6857
+ exports.isWhitespaceText = isWhitespaceText;
6831
6858
  exports.locStub = locStub;
6832
6859
  exports.noopDirectiveTransform = noopDirectiveTransform;
6833
6860
  exports.parse = parse;