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

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-dom v3.6.0-alpha.4
2
+ * @vue/compiler-dom v3.6.0-alpha.6
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) => {
@@ -6316,7 +6337,9 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
6316
6337
  `stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
6317
6338
  );
6318
6339
  const maybeKeyModifier = /* @__PURE__ */ makeMap("left,right");
6319
- const isKeyboardEvent = /* @__PURE__ */ makeMap(`onkeyup,onkeydown,onkeypress`);
6340
+ const isKeyboardEvent = /* @__PURE__ */ makeMap(
6341
+ `onkeyup,onkeydown,onkeypress`
6342
+ );
6320
6343
  const resolveModifiers = (key, modifiers, context, loc) => {
6321
6344
  const keyModifiers = [];
6322
6345
  const nonKeyModifiers = [];
@@ -6457,7 +6480,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
6457
6480
  }
6458
6481
  function defaultHasMultipleChildren(node) {
6459
6482
  const children = node.children = node.children.filter(
6460
- (c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
6483
+ (c) => !isCommentOrWhitespace(c)
6461
6484
  );
6462
6485
  const child = children[0];
6463
6486
  return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(defaultHasMultipleChildren);
@@ -6788,6 +6811,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
6788
6811
  exports.defaultOnWarn = defaultOnWarn;
6789
6812
  exports.errorMessages = errorMessages;
6790
6813
  exports.extractIdentifiers = extractIdentifiers;
6814
+ exports.filterNonCommentChildren = filterNonCommentChildren;
6791
6815
  exports.findDir = findDir;
6792
6816
  exports.findProp = findProp;
6793
6817
  exports.forAliasRE = forAliasRE;
@@ -6801,8 +6825,11 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
6801
6825
  exports.getVNodeHelper = getVNodeHelper;
6802
6826
  exports.hasDynamicKeyVBind = hasDynamicKeyVBind;
6803
6827
  exports.hasScopeRef = hasScopeRef;
6828
+ exports.hasSingleChild = hasSingleChild;
6804
6829
  exports.helperNameMap = helperNameMap;
6805
6830
  exports.injectProp = injectProp;
6831
+ exports.isAllWhitespace = isAllWhitespace;
6832
+ exports.isCommentOrWhitespace = isCommentOrWhitespace;
6806
6833
  exports.isConstantNode = isConstantNode;
6807
6834
  exports.isCoreComponent = isCoreComponent;
6808
6835
  exports.isFnExpression = isFnExpression;
@@ -6811,12 +6838,14 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
6811
6838
  exports.isFunctionType = isFunctionType;
6812
6839
  exports.isInDestructureAssignment = isInDestructureAssignment;
6813
6840
  exports.isInNewExpression = isInNewExpression;
6841
+ exports.isKeyboardEvent = isKeyboardEvent;
6814
6842
  exports.isLiteralWhitelisted = isLiteralWhitelisted;
6815
6843
  exports.isMemberExpression = isMemberExpression;
6816
6844
  exports.isMemberExpressionBrowser = isMemberExpressionBrowser;
6817
6845
  exports.isMemberExpressionNode = isMemberExpressionNode;
6818
6846
  exports.isReferencedIdentifier = isReferencedIdentifier;
6819
6847
  exports.isSimpleIdentifier = isSimpleIdentifier;
6848
+ exports.isSingleIfBlock = isSingleIfBlock;
6820
6849
  exports.isSlotOutlet = isSlotOutlet;
6821
6850
  exports.isStaticArgOf = isStaticArgOf;
6822
6851
  exports.isStaticExp = isStaticExp;
@@ -6828,6 +6857,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
6828
6857
  exports.isVPre = isVPre;
6829
6858
  exports.isVSlot = isVSlot;
6830
6859
  exports.isValidHTMLNesting = isValidHTMLNesting;
6860
+ exports.isWhitespaceText = isWhitespaceText;
6831
6861
  exports.locStub = locStub;
6832
6862
  exports.noopDirectiveTransform = noopDirectiveTransform;
6833
6863
  exports.parse = parse;