@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
  **/
@@ -306,7 +306,9 @@ const isNonKeyModifier = /* @__PURE__ */ shared.makeMap(
306
306
  `stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
307
307
  );
308
308
  const maybeKeyModifier = /* @__PURE__ */ shared.makeMap("left,right");
309
- const isKeyboardEvent = /* @__PURE__ */ shared.makeMap(`onkeyup,onkeydown,onkeypress`);
309
+ const isKeyboardEvent = /* @__PURE__ */ shared.makeMap(
310
+ `onkeyup,onkeydown,onkeypress`
311
+ );
310
312
  const resolveModifiers = (key, modifiers, context, loc) => {
311
313
  const keyModifiers = [];
312
314
  const nonKeyModifiers = [];
@@ -447,7 +449,7 @@ function postTransformTransition(node, onError, hasMultipleChildren = defaultHas
447
449
  }
448
450
  function defaultHasMultipleChildren(node) {
449
451
  const children = node.children = node.children.filter(
450
- (c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
452
+ (c) => !compilerCore.isCommentOrWhitespace(c)
451
453
  );
452
454
  const child = children[0];
453
455
  return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(defaultHasMultipleChildren);
@@ -929,6 +931,7 @@ exports.V_ON_WITH_MODIFIERS = V_ON_WITH_MODIFIERS;
929
931
  exports.V_SHOW = V_SHOW;
930
932
  exports.compile = compile;
931
933
  exports.createDOMCompilerError = createDOMCompilerError;
934
+ exports.isKeyboardEvent = isKeyboardEvent;
932
935
  exports.isValidHTMLNesting = isValidHTMLNesting;
933
936
  exports.parse = parse;
934
937
  exports.parserOptions = parserOptions;
@@ -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
  **/
@@ -288,7 +288,9 @@ const isNonKeyModifier = /* @__PURE__ */ shared.makeMap(
288
288
  `stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
289
289
  );
290
290
  const maybeKeyModifier = /* @__PURE__ */ shared.makeMap("left,right");
291
- const isKeyboardEvent = /* @__PURE__ */ shared.makeMap(`onkeyup,onkeydown,onkeypress`);
291
+ const isKeyboardEvent = /* @__PURE__ */ shared.makeMap(
292
+ `onkeyup,onkeydown,onkeypress`
293
+ );
292
294
  const resolveModifiers = (key, modifiers, context, loc) => {
293
295
  const keyModifiers = [];
294
296
  const nonKeyModifiers = [];
@@ -421,7 +423,7 @@ function postTransformTransition(node, onError, hasMultipleChildren = defaultHas
421
423
  }
422
424
  function defaultHasMultipleChildren(node) {
423
425
  const children = node.children = node.children.filter(
424
- (c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
426
+ (c) => !compilerCore.isCommentOrWhitespace(c)
425
427
  );
426
428
  const child = children[0];
427
429
  return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(defaultHasMultipleChildren);
@@ -887,6 +889,7 @@ exports.V_ON_WITH_MODIFIERS = V_ON_WITH_MODIFIERS;
887
889
  exports.V_SHOW = V_SHOW;
888
890
  exports.compile = compile;
889
891
  exports.createDOMCompilerError = createDOMCompilerError;
892
+ exports.isKeyboardEvent = isKeyboardEvent;
890
893
  exports.isValidHTMLNesting = isValidHTMLNesting;
891
894
  exports.parse = parse;
892
895
  exports.parserOptions = parserOptions;
@@ -36,6 +36,7 @@ export declare enum DOMErrorCodes {
36
36
  }
37
37
  export declare const DOMErrorMessages: Record<DOMErrorCodes, string>;
38
38
 
39
+ export declare const isKeyboardEvent: (key: string) => boolean;
39
40
  export declare const resolveModifiers: (key: ExpressionNode | string, modifiers: SimpleExpressionNode[], context: TransformContext | null, loc: SourceLocation) => {
40
41
  keyModifiers: string[];
41
42
  nonKeyModifiers: string[];
@@ -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
  **/
@@ -2101,7 +2101,43 @@ function getMemoedVNodeCall(node) {
2101
2101
  return node;
2102
2102
  }
2103
2103
  }
2104
+ function filterNonCommentChildren(node) {
2105
+ return node.children.filter((n) => n.type !== 3);
2106
+ }
2107
+ function hasSingleChild(node) {
2108
+ return filterNonCommentChildren(node).length === 1;
2109
+ }
2110
+ function isSingleIfBlock(parent) {
2111
+ let hasEncounteredIf = false;
2112
+ for (const c of filterNonCommentChildren(parent)) {
2113
+ if (c.type === 9 || c.type === 1 && findDir(c, "if")) {
2114
+ if (hasEncounteredIf) return false;
2115
+ hasEncounteredIf = true;
2116
+ } else if (
2117
+ // node before v-if
2118
+ !hasEncounteredIf || // non else nodes
2119
+ !(c.type === 1 && findDir(c, /^else(-if)?$/, true))
2120
+ ) {
2121
+ return false;
2122
+ }
2123
+ }
2124
+ return true;
2125
+ }
2104
2126
  const forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+(\S[\s\S]*)/;
2127
+ function isAllWhitespace(str) {
2128
+ for (let i = 0; i < str.length; i++) {
2129
+ if (!isWhitespace(str.charCodeAt(i))) {
2130
+ return false;
2131
+ }
2132
+ }
2133
+ return true;
2134
+ }
2135
+ function isWhitespaceText(node) {
2136
+ return node.type === 2 && isAllWhitespace(node.content) || node.type === 12 && isWhitespaceText(node.content);
2137
+ }
2138
+ function isCommentOrWhitespace(node) {
2139
+ return node.type === 3 || isWhitespaceText(node);
2140
+ }
2105
2141
 
2106
2142
  const defaultParserOptions = {
2107
2143
  parseMode: "base",
@@ -2724,14 +2760,6 @@ function condenseWhitespace(nodes) {
2724
2760
  }
2725
2761
  return removedWhitespace ? nodes.filter(Boolean) : nodes;
2726
2762
  }
2727
- function isAllWhitespace(str) {
2728
- for (let i = 0; i < str.length; i++) {
2729
- if (!isWhitespace(str.charCodeAt(i))) {
2730
- return false;
2731
- }
2732
- }
2733
- return true;
2734
- }
2735
2763
  function hasNewlineChar(str) {
2736
2764
  for (let i = 0; i < str.length; i++) {
2737
2765
  const c = str.charCodeAt(i);
@@ -4175,13 +4203,11 @@ function processIf(node, dir, context, processCodegen) {
4175
4203
  let i = siblings.indexOf(node);
4176
4204
  while (i-- >= -1) {
4177
4205
  const sibling = siblings[i];
4178
- if (sibling && sibling.type === 3) {
4179
- context.removeNode(sibling);
4180
- comments.unshift(sibling);
4181
- continue;
4182
- }
4183
- if (sibling && sibling.type === 2 && !sibling.content.trim().length) {
4206
+ if (sibling && isCommentOrWhitespace(sibling)) {
4184
4207
  context.removeNode(sibling);
4208
+ if (sibling.type === 3) {
4209
+ comments.unshift(sibling);
4210
+ }
4185
4211
  continue;
4186
4212
  }
4187
4213
  if (sibling && sibling.type === 9) {
@@ -4653,7 +4679,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
4653
4679
  let prev;
4654
4680
  while (j--) {
4655
4681
  prev = children[j];
4656
- if (prev.type !== 3 && isNonWhitespaceContent(prev)) {
4682
+ if (!isCommentOrWhitespace(prev)) {
4657
4683
  break;
4658
4684
  }
4659
4685
  }
@@ -4731,7 +4757,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
4731
4757
  } else if (implicitDefaultChildren.length && // #3766
4732
4758
  // with whitespace: 'preserve', whitespaces between slots will end up in
4733
4759
  // implicitDefaultChildren. Ignore if all implicit children are whitespaces.
4734
- implicitDefaultChildren.some((node2) => isNonWhitespaceContent(node2))) {
4760
+ !implicitDefaultChildren.every(isWhitespaceText)) {
4735
4761
  if (hasNamedDefaultSlot) {
4736
4762
  context.onError(
4737
4763
  createCompilerError(
@@ -4804,11 +4830,6 @@ function hasForwardedSlots(children) {
4804
4830
  }
4805
4831
  return false;
4806
4832
  }
4807
- function isNonWhitespaceContent(node) {
4808
- if (node.type !== 2 && node.type !== 12)
4809
- return true;
4810
- return node.type === 2 ? !!node.content.trim() : isNonWhitespaceContent(node.content);
4811
- }
4812
4833
 
4813
4834
  const directiveImportMap = /* @__PURE__ */ new WeakMap();
4814
4835
  const transformElement = (node, context) => {
@@ -6313,7 +6334,9 @@ const isNonKeyModifier = /* @__PURE__ */ makeMap(
6313
6334
  `stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
6314
6335
  );
6315
6336
  const maybeKeyModifier = /* @__PURE__ */ makeMap("left,right");
6316
- const isKeyboardEvent = /* @__PURE__ */ makeMap(`onkeyup,onkeydown,onkeypress`);
6337
+ const isKeyboardEvent = /* @__PURE__ */ makeMap(
6338
+ `onkeyup,onkeydown,onkeypress`
6339
+ );
6317
6340
  const resolveModifiers = (key, modifiers, context, loc) => {
6318
6341
  const keyModifiers = [];
6319
6342
  const nonKeyModifiers = [];
@@ -6454,7 +6477,7 @@ function postTransformTransition(node, onError, hasMultipleChildren = defaultHas
6454
6477
  }
6455
6478
  function defaultHasMultipleChildren(node) {
6456
6479
  const children = node.children = node.children.filter(
6457
- (c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
6480
+ (c) => !isCommentOrWhitespace(c)
6458
6481
  );
6459
6482
  const child = children[0];
6460
6483
  return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(defaultHasMultipleChildren);
@@ -6686,4 +6709,4 @@ function parse(template, options = {}) {
6686
6709
  return baseParse(template, extend({}, parserOptions, options));
6687
6710
  }
6688
6711
 
6689
- export { BASE_TRANSITION, BindingTypes, CAMELIZE, CAPITALIZE, CREATE_BLOCK, CREATE_COMMENT, CREATE_ELEMENT_BLOCK, CREATE_ELEMENT_VNODE, CREATE_SLOTS, CREATE_STATIC, CREATE_TEXT, CREATE_VNODE, CompilerDeprecationTypes, ConstantTypes, DOMDirectiveTransforms, DOMErrorCodes, DOMErrorMessages, DOMNodeTransforms, ElementTypes, ErrorCodes, FRAGMENT, GUARD_REACTIVE_PROPS, IS_MEMO_SAME, IS_REF, KEEP_ALIVE, MERGE_PROPS, NORMALIZE_CLASS, NORMALIZE_PROPS, NORMALIZE_STYLE, NewlineType, NodeTypes, OPEN_BLOCK, POP_SCOPE_ID, PUSH_SCOPE_ID, RENDER_LIST, RENDER_SLOT, RESOLVE_COMPONENT, RESOLVE_DIRECTIVE, RESOLVE_DYNAMIC_COMPONENT, RESOLVE_FILTER, SET_BLOCK_TRACKING, SUSPENSE, TELEPORT, TO_DISPLAY_STRING, TO_HANDLERS, TO_HANDLER_KEY, TRANSITION, TRANSITION_GROUP, TS_NODE_TYPES, UNREF, V_MODEL_CHECKBOX, V_MODEL_DYNAMIC, V_MODEL_RADIO, V_MODEL_SELECT, V_MODEL_TEXT, V_ON_WITH_KEYS, V_ON_WITH_MODIFIERS, V_SHOW, WITH_CTX, WITH_DIRECTIVES, WITH_MEMO, advancePositionWithClone, advancePositionWithMutation, assert, baseCompile, baseParse, buildDirectiveArgs, buildProps, buildSlots, checkCompatEnabled, compile, convertToBlock, createArrayExpression, createAssignmentExpression, createBlockStatement, createCacheExpression, createCallExpression, createCompilerError, createCompoundExpression, createConditionalExpression, createDOMCompilerError, createForLoopParams, createFunctionExpression, createIfStatement, createInterpolation, createObjectExpression, createObjectProperty, createReturnStatement, createRoot, createSequenceExpression, createSimpleExpression, createStructuralDirectiveTransform, createTemplateLiteral, createTransformContext, createVNodeCall, defaultOnError, defaultOnWarn, errorMessages, extractIdentifiers, findDir, findProp, forAliasRE, generate, generateCodeFrame, getBaseTransformPreset, getConstantType, getMemoedVNodeCall, getSelfName, getVNodeBlockHelper, getVNodeHelper, hasDynamicKeyVBind, hasScopeRef, helperNameMap, injectProp, isConstantNode, isCoreComponent, isFnExpression, isFnExpressionBrowser, isFnExpressionNode, isFunctionType, isInDestructureAssignment, isInNewExpression, isLiteralWhitelisted, isMemberExpression, isMemberExpressionBrowser, isMemberExpressionNode, isReferencedIdentifier, isSimpleIdentifier, isSlotOutlet, isStaticArgOf, isStaticExp, isStaticNode, isStaticProperty, isStaticPropertyKey, isTemplateNode, isText$1 as isText, isVPre, isVSlot, isValidHTMLNesting, locStub, noopDirectiveTransform, parse, parserOptions, postTransformTransition, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, resolveModifiers, stringifyExpression, toValidAssetId, trackSlotScopes, trackVForSlotScopes, transform, transformBind, transformElement, transformExpression, transformModel$1 as transformModel, transformOn$1 as transformOn, transformStyle, transformVBindShorthand, traverseNode, unwrapTSNode, validFirstIdentCharRE, walkBlockDeclarations, walkFunctionParams, walkIdentifiers, warnDeprecation };
6712
+ export { BASE_TRANSITION, BindingTypes, CAMELIZE, CAPITALIZE, CREATE_BLOCK, CREATE_COMMENT, CREATE_ELEMENT_BLOCK, CREATE_ELEMENT_VNODE, CREATE_SLOTS, CREATE_STATIC, CREATE_TEXT, CREATE_VNODE, CompilerDeprecationTypes, ConstantTypes, DOMDirectiveTransforms, DOMErrorCodes, DOMErrorMessages, DOMNodeTransforms, ElementTypes, ErrorCodes, FRAGMENT, GUARD_REACTIVE_PROPS, IS_MEMO_SAME, IS_REF, KEEP_ALIVE, MERGE_PROPS, NORMALIZE_CLASS, NORMALIZE_PROPS, NORMALIZE_STYLE, NewlineType, NodeTypes, OPEN_BLOCK, POP_SCOPE_ID, PUSH_SCOPE_ID, RENDER_LIST, RENDER_SLOT, RESOLVE_COMPONENT, RESOLVE_DIRECTIVE, RESOLVE_DYNAMIC_COMPONENT, RESOLVE_FILTER, SET_BLOCK_TRACKING, SUSPENSE, TELEPORT, TO_DISPLAY_STRING, TO_HANDLERS, TO_HANDLER_KEY, TRANSITION, TRANSITION_GROUP, TS_NODE_TYPES, UNREF, V_MODEL_CHECKBOX, V_MODEL_DYNAMIC, V_MODEL_RADIO, V_MODEL_SELECT, V_MODEL_TEXT, V_ON_WITH_KEYS, V_ON_WITH_MODIFIERS, V_SHOW, WITH_CTX, WITH_DIRECTIVES, WITH_MEMO, advancePositionWithClone, advancePositionWithMutation, assert, baseCompile, baseParse, buildDirectiveArgs, buildProps, buildSlots, checkCompatEnabled, compile, convertToBlock, createArrayExpression, createAssignmentExpression, createBlockStatement, createCacheExpression, createCallExpression, createCompilerError, createCompoundExpression, createConditionalExpression, createDOMCompilerError, createForLoopParams, createFunctionExpression, createIfStatement, createInterpolation, createObjectExpression, createObjectProperty, createReturnStatement, createRoot, createSequenceExpression, createSimpleExpression, createStructuralDirectiveTransform, createTemplateLiteral, createTransformContext, createVNodeCall, defaultOnError, defaultOnWarn, errorMessages, extractIdentifiers, filterNonCommentChildren, findDir, findProp, forAliasRE, generate, generateCodeFrame, getBaseTransformPreset, getConstantType, getMemoedVNodeCall, getSelfName, getVNodeBlockHelper, getVNodeHelper, hasDynamicKeyVBind, hasScopeRef, hasSingleChild, helperNameMap, injectProp, isAllWhitespace, isCommentOrWhitespace, isConstantNode, isCoreComponent, isFnExpression, isFnExpressionBrowser, isFnExpressionNode, isFunctionType, isInDestructureAssignment, isInNewExpression, isKeyboardEvent, isLiteralWhitelisted, isMemberExpression, isMemberExpressionBrowser, isMemberExpressionNode, isReferencedIdentifier, isSimpleIdentifier, isSingleIfBlock, isSlotOutlet, isStaticArgOf, isStaticExp, isStaticNode, isStaticProperty, isStaticPropertyKey, isTemplateNode, isText$1 as isText, isVPre, isVSlot, isValidHTMLNesting, isWhitespaceText, locStub, noopDirectiveTransform, parse, parserOptions, postTransformTransition, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, resolveModifiers, stringifyExpression, toValidAssetId, trackSlotScopes, trackVForSlotScopes, transform, transformBind, transformElement, transformExpression, transformModel$1 as transformModel, transformOn$1 as transformOn, transformStyle, transformVBindShorthand, traverseNode, unwrapTSNode, validFirstIdentCharRE, walkBlockDeclarations, walkFunctionParams, walkIdentifiers, warnDeprecation };