@vue/compiler-dom 3.5.20 → 3.5.22

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.5.20
2
+ * @vue/compiler-dom v3.5.22
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -522,7 +522,7 @@ const getCachedNode = (node) => {
522
522
  return node.codegenNode;
523
523
  }
524
524
  };
525
- const dataAriaRE = /^(data|aria)-/;
525
+ const dataAriaRE = /^(?:data|aria)-/;
526
526
  const isStringifiableAttr = (name, ns) => {
527
527
  return (ns === 0 ? shared.isKnownHtmlAttr(name) : ns === 1 ? shared.isKnownSvgAttr(name) : ns === 2 ? shared.isKnownMathMLAttr(name) : false) || dataAriaRE.test(name);
528
528
  };
@@ -533,6 +533,9 @@ function analyzeNode(node) {
533
533
  if (node.type === 1 && isNonStringifiable(node.tag)) {
534
534
  return false;
535
535
  }
536
+ if (node.type === 1 && compilerCore.findDir(node, "once", true)) {
537
+ return false;
538
+ }
536
539
  if (node.type === 12) {
537
540
  return [1, 0];
538
541
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-dom v3.5.20
2
+ * @vue/compiler-dom v3.5.22
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -458,7 +458,7 @@ const getCachedNode = (node) => {
458
458
  return node.codegenNode;
459
459
  }
460
460
  };
461
- const dataAriaRE = /^(data|aria)-/;
461
+ const dataAriaRE = /^(?:data|aria)-/;
462
462
  const isStringifiableAttr = (name, ns) => {
463
463
  return (ns === 0 ? shared.isKnownHtmlAttr(name) : ns === 1 ? shared.isKnownSvgAttr(name) : ns === 2 ? shared.isKnownMathMLAttr(name) : false) || dataAriaRE.test(name);
464
464
  };
@@ -469,6 +469,9 @@ function analyzeNode(node) {
469
469
  if (node.type === 1 && isNonStringifiable(node.tag)) {
470
470
  return false;
471
471
  }
472
+ if (node.type === 1 && compilerCore.findDir(node, "once", true)) {
473
+ return false;
474
+ }
472
475
  if (node.type === 12) {
473
476
  return [1, 0];
474
477
  }
@@ -1,9 +1,8 @@
1
1
  /**
2
- * @vue/compiler-dom v3.5.20
2
+ * @vue/compiler-dom v3.5.22
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
6
- /*! #__NO_SIDE_EFFECTS__ */
7
6
  // @__NO_SIDE_EFFECTS__
8
7
  function makeMap(str) {
9
8
  const map = /* @__PURE__ */ Object.create(null);
@@ -36,10 +35,10 @@ const cacheStringFunction = (fn) => {
36
35
  return hit || (cache[str] = fn(str));
37
36
  });
38
37
  };
39
- const camelizeRE = /-(\w)/g;
38
+ const camelizeRE = /-\w/g;
40
39
  const camelize = cacheStringFunction(
41
40
  (str) => {
42
- return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
41
+ return str.replace(camelizeRE, (c) => c.slice(1).toUpperCase());
43
42
  }
44
43
  );
45
44
  const capitalize = cacheStringFunction((str) => {
@@ -1648,7 +1647,8 @@ function walkFunctionParams(node, onIdent) {
1648
1647
  }
1649
1648
  }
1650
1649
  function walkBlockDeclarations(block, onIdent) {
1651
- for (const stmt of block.body) {
1650
+ const body = block.type === "SwitchCase" ? block.consequent : block.body;
1651
+ for (const stmt of body) {
1652
1652
  if (stmt.type === "VariableDeclaration") {
1653
1653
  if (stmt.declare) continue;
1654
1654
  for (const decl of stmt.declarations) {
@@ -1661,6 +1661,8 @@ function walkBlockDeclarations(block, onIdent) {
1661
1661
  onIdent(stmt.id);
1662
1662
  } else if (isForStatement(stmt)) {
1663
1663
  walkForStatement(stmt, true, onIdent);
1664
+ } else if (stmt.type === "SwitchStatement") {
1665
+ walkSwitchStatement(stmt, true, onIdent);
1664
1666
  }
1665
1667
  }
1666
1668
  }
@@ -1677,6 +1679,20 @@ function walkForStatement(stmt, isVar, onIdent) {
1677
1679
  }
1678
1680
  }
1679
1681
  }
1682
+ function walkSwitchStatement(stmt, isVar, onIdent) {
1683
+ for (const cs of stmt.cases) {
1684
+ for (const stmt2 of cs.consequent) {
1685
+ if (stmt2.type === "VariableDeclaration" && (stmt2.kind === "var" ? isVar : !isVar)) {
1686
+ for (const decl of stmt2.declarations) {
1687
+ for (const id of extractIdentifiers(decl.id)) {
1688
+ onIdent(id);
1689
+ }
1690
+ }
1691
+ }
1692
+ }
1693
+ walkBlockDeclarations(cs, onIdent);
1694
+ }
1695
+ }
1680
1696
  function extractIdentifiers(param, nodes = []) {
1681
1697
  switch (param.type) {
1682
1698
  case "Identifier":
@@ -1824,7 +1840,7 @@ const isMemberExpressionBrowser = (exp) => {
1824
1840
  };
1825
1841
  const isMemberExpressionNode = NOOP ;
1826
1842
  const isMemberExpression = isMemberExpressionBrowser ;
1827
- const fnExpRE = /^\s*(async\s*)?(\([^)]*?\)|[\w$_]+)\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
1843
+ const fnExpRE = /^\s*(?:async\s*)?(?:\([^)]*?\)|[\w$_]+)\s*(?::[^=]+)?=>|^\s*(?:async\s+)?function(?:\s+[\w$]+)?\s*\(/;
1828
1844
  const isFnExpressionBrowser = (exp) => fnExpRE.test(getExpSource(exp));
1829
1845
  const isFnExpressionNode = NOOP ;
1830
1846
  const isFnExpression = isFnExpressionBrowser ;
@@ -4038,7 +4054,7 @@ function stringifyExpression(exp) {
4038
4054
  }
4039
4055
 
4040
4056
  const transformIf = createStructuralDirectiveTransform(
4041
- /^(if|else|else-if)$/,
4057
+ /^(?:if|else|else-if)$/,
4042
4058
  (node, dir, context) => {
4043
4059
  return processIf(node, dir, context, (ifNode, branch, isRoot) => {
4044
4060
  const siblings = context.parent.children;
@@ -4256,80 +4272,6 @@ function getParentCondition(node) {
4256
4272
  }
4257
4273
  }
4258
4274
 
4259
- const transformBind = (dir, _node, context) => {
4260
- const { modifiers, loc } = dir;
4261
- const arg = dir.arg;
4262
- let { exp } = dir;
4263
- if (exp && exp.type === 4 && !exp.content.trim()) {
4264
- {
4265
- exp = void 0;
4266
- }
4267
- }
4268
- if (!exp) {
4269
- if (arg.type !== 4 || !arg.isStatic) {
4270
- context.onError(
4271
- createCompilerError(
4272
- 52,
4273
- arg.loc
4274
- )
4275
- );
4276
- return {
4277
- props: [
4278
- createObjectProperty(arg, createSimpleExpression("", true, loc))
4279
- ]
4280
- };
4281
- }
4282
- transformBindShorthand(dir);
4283
- exp = dir.exp;
4284
- }
4285
- if (arg.type !== 4) {
4286
- arg.children.unshift(`(`);
4287
- arg.children.push(`) || ""`);
4288
- } else if (!arg.isStatic) {
4289
- arg.content = arg.content ? `${arg.content} || ""` : `""`;
4290
- }
4291
- if (modifiers.some((mod) => mod.content === "camel")) {
4292
- if (arg.type === 4) {
4293
- if (arg.isStatic) {
4294
- arg.content = camelize(arg.content);
4295
- } else {
4296
- arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
4297
- }
4298
- } else {
4299
- arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
4300
- arg.children.push(`)`);
4301
- }
4302
- }
4303
- if (!context.inSSR) {
4304
- if (modifiers.some((mod) => mod.content === "prop")) {
4305
- injectPrefix(arg, ".");
4306
- }
4307
- if (modifiers.some((mod) => mod.content === "attr")) {
4308
- injectPrefix(arg, "^");
4309
- }
4310
- }
4311
- return {
4312
- props: [createObjectProperty(arg, exp)]
4313
- };
4314
- };
4315
- const transformBindShorthand = (dir, context) => {
4316
- const arg = dir.arg;
4317
- const propName = camelize(arg.content);
4318
- dir.exp = createSimpleExpression(propName, false, arg.loc);
4319
- };
4320
- const injectPrefix = (arg, prefix) => {
4321
- if (arg.type === 4) {
4322
- if (arg.isStatic) {
4323
- arg.content = prefix + arg.content;
4324
- } else {
4325
- arg.content = `\`${prefix}\${${arg.content}}\``;
4326
- }
4327
- } else {
4328
- arg.children.unshift(`'${prefix}' + (`);
4329
- arg.children.push(`)`);
4330
- }
4331
- };
4332
-
4333
4275
  const transformFor = createStructuralDirectiveTransform(
4334
4276
  "for",
4335
4277
  (node, dir, context) => {
@@ -4341,10 +4283,7 @@ const transformFor = createStructuralDirectiveTransform(
4341
4283
  const isTemplate = isTemplateNode(node);
4342
4284
  const memo = findDir(node, "memo");
4343
4285
  const keyProp = findProp(node, `key`, false, true);
4344
- const isDirKey = keyProp && keyProp.type === 7;
4345
- if (isDirKey && !keyProp.exp) {
4346
- transformBindShorthand(keyProp);
4347
- }
4286
+ keyProp && keyProp.type === 7;
4348
4287
  let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
4349
4288
  const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
4350
4289
  const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
@@ -4644,7 +4583,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
4644
4583
  );
4645
4584
  } else if (vElse = findDir(
4646
4585
  slotElement,
4647
- /^else(-if)?$/,
4586
+ /^else(?:-if)?$/,
4648
4587
  true
4649
4588
  /* allowEmpty */
4650
4589
  )) {
@@ -4656,7 +4595,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
4656
4595
  break;
4657
4596
  }
4658
4597
  }
4659
- if (prev && isTemplateNode(prev) && findDir(prev, /^(else-)?if$/)) {
4598
+ if (prev && isTemplateNode(prev) && findDir(prev, /^(?:else-)?if$/)) {
4660
4599
  let conditional = dynamicSlots[dynamicSlots.length - 1];
4661
4600
  while (conditional.alternate.type === 19) {
4662
4601
  conditional = conditional.alternate;
@@ -5516,6 +5455,58 @@ const transformOn$1 = (dir, node, context, augmentor) => {
5516
5455
  return ret;
5517
5456
  };
5518
5457
 
5458
+ const transformBind = (dir, _node, context) => {
5459
+ const { modifiers, loc } = dir;
5460
+ const arg = dir.arg;
5461
+ let { exp } = dir;
5462
+ if (exp && exp.type === 4 && !exp.content.trim()) {
5463
+ {
5464
+ exp = void 0;
5465
+ }
5466
+ }
5467
+ if (arg.type !== 4) {
5468
+ arg.children.unshift(`(`);
5469
+ arg.children.push(`) || ""`);
5470
+ } else if (!arg.isStatic) {
5471
+ arg.content = arg.content ? `${arg.content} || ""` : `""`;
5472
+ }
5473
+ if (modifiers.some((mod) => mod.content === "camel")) {
5474
+ if (arg.type === 4) {
5475
+ if (arg.isStatic) {
5476
+ arg.content = camelize(arg.content);
5477
+ } else {
5478
+ arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
5479
+ }
5480
+ } else {
5481
+ arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
5482
+ arg.children.push(`)`);
5483
+ }
5484
+ }
5485
+ if (!context.inSSR) {
5486
+ if (modifiers.some((mod) => mod.content === "prop")) {
5487
+ injectPrefix(arg, ".");
5488
+ }
5489
+ if (modifiers.some((mod) => mod.content === "attr")) {
5490
+ injectPrefix(arg, "^");
5491
+ }
5492
+ }
5493
+ return {
5494
+ props: [createObjectProperty(arg, exp)]
5495
+ };
5496
+ };
5497
+ const injectPrefix = (arg, prefix) => {
5498
+ if (arg.type === 4) {
5499
+ if (arg.isStatic) {
5500
+ arg.content = prefix + arg.content;
5501
+ } else {
5502
+ arg.content = `\`${prefix}\${${arg.content}}\``;
5503
+ }
5504
+ } else {
5505
+ arg.children.unshift(`'${prefix}' + (`);
5506
+ arg.children.push(`)`);
5507
+ }
5508
+ };
5509
+
5519
5510
  const transformText = (node, context) => {
5520
5511
  if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
5521
5512
  return () => {
@@ -5846,9 +5837,35 @@ const transformMemo = (node, context) => {
5846
5837
  }
5847
5838
  };
5848
5839
 
5840
+ const transformVBindShorthand = (node, context) => {
5841
+ if (node.type === 1) {
5842
+ for (const prop of node.props) {
5843
+ if (prop.type === 7 && prop.name === "bind" && !prop.exp) {
5844
+ const arg = prop.arg;
5845
+ if (arg.type !== 4 || !arg.isStatic) {
5846
+ context.onError(
5847
+ createCompilerError(
5848
+ 52,
5849
+ arg.loc
5850
+ )
5851
+ );
5852
+ prop.exp = createSimpleExpression("", true, arg.loc);
5853
+ } else {
5854
+ const propName = camelize(arg.content);
5855
+ if (validFirstIdentCharRE.test(propName[0]) || // allow hyphen first char for https://github.com/vuejs/language-tools/pull/3424
5856
+ propName[0] === "-") {
5857
+ prop.exp = createSimpleExpression(propName, false, arg.loc);
5858
+ }
5859
+ }
5860
+ }
5861
+ }
5862
+ }
5863
+ };
5864
+
5849
5865
  function getBaseTransformPreset(prefixIdentifiers) {
5850
5866
  return [
5851
5867
  [
5868
+ transformVBindShorthand,
5852
5869
  transformOnce,
5853
5870
  transformIf,
5854
5871
  transformMemo,
@@ -6603,4 +6620,4 @@ function parse(template, options = {}) {
6603
6620
  return baseParse(template, extend({}, parserOptions, options));
6604
6621
  }
6605
6622
 
6606
- 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, Namespaces, 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, errorMessages, extractIdentifiers, findDir, findProp, forAliasRE, generate, generateCodeFrame, getBaseTransformPreset, getConstantType, getMemoedVNodeCall, getVNodeBlockHelper, getVNodeHelper, hasDynamicKeyVBind, hasScopeRef, helperNameMap, injectProp, isCoreComponent, isFnExpression, isFnExpressionBrowser, isFnExpressionNode, isFunctionType, isInDestructureAssignment, isInNewExpression, isMemberExpression, isMemberExpressionBrowser, isMemberExpressionNode, isReferencedIdentifier, isSimpleIdentifier, isSlotOutlet, isStaticArgOf, isStaticExp, isStaticProperty, isStaticPropertyKey, isTemplateNode, isText$1 as isText, isVPre, isVSlot, locStub, noopDirectiveTransform, parse, parserOptions, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, stringifyExpression, toValidAssetId, trackSlotScopes, trackVForSlotScopes, transform, transformBind, transformElement, transformExpression, transformModel$1 as transformModel, transformOn$1 as transformOn, transformStyle, traverseNode, unwrapTSNode, walkBlockDeclarations, walkFunctionParams, walkIdentifiers, warnDeprecation };
6623
+ 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, Namespaces, 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, errorMessages, extractIdentifiers, findDir, findProp, forAliasRE, generate, generateCodeFrame, getBaseTransformPreset, getConstantType, getMemoedVNodeCall, getVNodeBlockHelper, getVNodeHelper, hasDynamicKeyVBind, hasScopeRef, helperNameMap, injectProp, isCoreComponent, isFnExpression, isFnExpressionBrowser, isFnExpressionNode, isFunctionType, isInDestructureAssignment, isInNewExpression, isMemberExpression, isMemberExpressionBrowser, isMemberExpressionNode, isReferencedIdentifier, isSimpleIdentifier, isSlotOutlet, isStaticArgOf, isStaticExp, isStaticProperty, isStaticPropertyKey, isTemplateNode, isText$1 as isText, isVPre, isVSlot, locStub, noopDirectiveTransform, parse, parserOptions, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, 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 };