@vue/compiler-dom 3.5.3 → 3.5.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,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-dom v3.5.3
2
+ * @vue/compiler-dom v3.5.5
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -50,6 +50,7 @@ const parserOptions = {
50
50
  isVoidTag: shared.isVoidTag,
51
51
  isNativeTag: (tag) => shared.isHTMLTag(tag) || shared.isSVGTag(tag) || shared.isMathMLTag(tag),
52
52
  isPreTag: (tag) => tag === "pre",
53
+ isIgnoreNewlineTag: (tag) => tag === "pre" || tag === "textarea",
53
54
  decodeEntities: void 0,
54
55
  isBuiltInComponent: (tag) => {
55
56
  if (tag === "Transition" || tag === "transition") {
@@ -303,10 +304,7 @@ const isNonKeyModifier = /* @__PURE__ */ shared.makeMap(
303
304
  `stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
304
305
  );
305
306
  const maybeKeyModifier = /* @__PURE__ */ shared.makeMap("left,right");
306
- const isKeyboardEvent = /* @__PURE__ */ shared.makeMap(
307
- `onkeyup,onkeydown,onkeypress`,
308
- true
309
- );
307
+ const isKeyboardEvent = /* @__PURE__ */ shared.makeMap(`onkeyup,onkeydown,onkeypress`);
310
308
  const resolveModifiers = (key, modifiers, context, loc) => {
311
309
  const keyModifiers = [];
312
310
  const nonKeyModifiers = [];
@@ -324,7 +322,7 @@ const resolveModifiers = (key, modifiers, context, loc) => {
324
322
  } else {
325
323
  if (maybeKeyModifier(modifier)) {
326
324
  if (compilerCore.isStaticExp(key)) {
327
- if (isKeyboardEvent(key.content)) {
325
+ if (isKeyboardEvent(key.content.toLowerCase())) {
328
326
  keyModifiers.push(modifier);
329
327
  } else {
330
328
  nonKeyModifiers.push(modifier);
@@ -377,7 +375,7 @@ const transformOn = (dir, node, context) => {
377
375
  ]);
378
376
  }
379
377
  if (keyModifiers.length && // if event name is dynamic, always wrap with keys guard
380
- (!compilerCore.isStaticExp(key) || isKeyboardEvent(key.content))) {
378
+ (!compilerCore.isStaticExp(key) || isKeyboardEvent(key.content.toLowerCase()))) {
381
379
  handlerExp = compilerCore.createCallExpression(context.helper(V_ON_WITH_KEYS), [
382
380
  handlerExp,
383
381
  JSON.stringify(keyModifiers)
@@ -471,12 +469,17 @@ const stringifyStatic = (children, context, parent) => {
471
469
  // will insert / hydrate
472
470
  String(currentChunk.length)
473
471
  ]);
472
+ const deleteCount = currentChunk.length - 1;
474
473
  if (isParentCached) {
475
- parent.codegenNode.children.value = compilerCore.createArrayExpression([staticCall]);
474
+ children.splice(
475
+ currentIndex - currentChunk.length,
476
+ currentChunk.length,
477
+ // @ts-expect-error
478
+ staticCall
479
+ );
476
480
  } else {
477
481
  currentChunk[0].codegenNode.value = staticCall;
478
482
  if (currentChunk.length > 1) {
479
- const deleteCount = currentChunk.length - 1;
480
483
  children.splice(currentIndex - currentChunk.length + 1, deleteCount);
481
484
  const cacheIndex = context.cached.indexOf(
482
485
  currentChunk[currentChunk.length - 1].codegenNode
@@ -488,9 +491,9 @@ const stringifyStatic = (children, context, parent) => {
488
491
  }
489
492
  context.cached.splice(cacheIndex - deleteCount + 1, deleteCount);
490
493
  }
491
- return deleteCount;
492
494
  }
493
495
  }
496
+ return deleteCount;
494
497
  }
495
498
  return 0;
496
499
  };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-dom v3.5.3
2
+ * @vue/compiler-dom v3.5.5
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -50,6 +50,7 @@ const parserOptions = {
50
50
  isVoidTag: shared.isVoidTag,
51
51
  isNativeTag: (tag) => shared.isHTMLTag(tag) || shared.isSVGTag(tag) || shared.isMathMLTag(tag),
52
52
  isPreTag: (tag) => tag === "pre",
53
+ isIgnoreNewlineTag: (tag) => tag === "pre" || tag === "textarea",
53
54
  decodeEntities: void 0,
54
55
  isBuiltInComponent: (tag) => {
55
56
  if (tag === "Transition" || tag === "transition") {
@@ -285,10 +286,7 @@ const isNonKeyModifier = /* @__PURE__ */ shared.makeMap(
285
286
  `stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
286
287
  );
287
288
  const maybeKeyModifier = /* @__PURE__ */ shared.makeMap("left,right");
288
- const isKeyboardEvent = /* @__PURE__ */ shared.makeMap(
289
- `onkeyup,onkeydown,onkeypress`,
290
- true
291
- );
289
+ const isKeyboardEvent = /* @__PURE__ */ shared.makeMap(`onkeyup,onkeydown,onkeypress`);
292
290
  const resolveModifiers = (key, modifiers, context, loc) => {
293
291
  const keyModifiers = [];
294
292
  const nonKeyModifiers = [];
@@ -306,7 +304,7 @@ const resolveModifiers = (key, modifiers, context, loc) => {
306
304
  } else {
307
305
  if (maybeKeyModifier(modifier)) {
308
306
  if (compilerCore.isStaticExp(key)) {
309
- if (isKeyboardEvent(key.content)) {
307
+ if (isKeyboardEvent(key.content.toLowerCase())) {
310
308
  keyModifiers.push(modifier);
311
309
  } else {
312
310
  nonKeyModifiers.push(modifier);
@@ -359,7 +357,7 @@ const transformOn = (dir, node, context) => {
359
357
  ]);
360
358
  }
361
359
  if (keyModifiers.length && // if event name is dynamic, always wrap with keys guard
362
- (!compilerCore.isStaticExp(key) || isKeyboardEvent(key.content))) {
360
+ (!compilerCore.isStaticExp(key) || isKeyboardEvent(key.content.toLowerCase()))) {
363
361
  handlerExp = compilerCore.createCallExpression(context.helper(V_ON_WITH_KEYS), [
364
362
  handlerExp,
365
363
  JSON.stringify(keyModifiers)
@@ -407,12 +405,17 @@ const stringifyStatic = (children, context, parent) => {
407
405
  // will insert / hydrate
408
406
  String(currentChunk.length)
409
407
  ]);
408
+ const deleteCount = currentChunk.length - 1;
410
409
  if (isParentCached) {
411
- parent.codegenNode.children.value = compilerCore.createArrayExpression([staticCall]);
410
+ children.splice(
411
+ currentIndex - currentChunk.length,
412
+ currentChunk.length,
413
+ // @ts-expect-error
414
+ staticCall
415
+ );
412
416
  } else {
413
417
  currentChunk[0].codegenNode.value = staticCall;
414
418
  if (currentChunk.length > 1) {
415
- const deleteCount = currentChunk.length - 1;
416
419
  children.splice(currentIndex - currentChunk.length + 1, deleteCount);
417
420
  const cacheIndex = context.cached.indexOf(
418
421
  currentChunk[currentChunk.length - 1].codegenNode
@@ -424,9 +427,9 @@ const stringifyStatic = (children, context, parent) => {
424
427
  }
425
428
  context.cached.splice(cacheIndex - deleteCount + 1, deleteCount);
426
429
  }
427
- return deleteCount;
428
430
  }
429
431
  }
432
+ return deleteCount;
430
433
  }
431
434
  return 0;
432
435
  };
@@ -1,13 +1,14 @@
1
1
  /**
2
- * @vue/compiler-dom v3.5.3
2
+ * @vue/compiler-dom v3.5.5
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
6
6
  /*! #__NO_SIDE_EFFECTS__ */
7
7
  // @__NO_SIDE_EFFECTS__
8
- function makeMap(str, expectsLowerCase) {
9
- const set = new Set(str.split(","));
10
- return expectsLowerCase ? (val) => set.has(val.toLowerCase()) : (val) => set.has(val);
8
+ function makeMap(str) {
9
+ const map = /* @__PURE__ */ Object.create(null);
10
+ for (const key of str.split(",")) map[key] = 1;
11
+ return (val) => val in map;
11
12
  }
12
13
 
13
14
  const EMPTY_OBJ = Object.freeze({}) ;
@@ -752,7 +753,7 @@ class Tokenizer {
752
753
  this.sequenceIndex += 1;
753
754
  } else if (this.sequenceIndex === 0) {
754
755
  if (this.currentSequence === Sequences.TitleEnd || this.currentSequence === Sequences.TextareaEnd && !this.inSFCRoot) {
755
- if (c === this.delimiterOpen[0]) {
756
+ if (!this.inVPre && c === this.delimiterOpen[0]) {
756
757
  this.state = 2;
757
758
  this.delimiterIndex = 0;
758
759
  this.stateInterpolationOpen(c);
@@ -2042,6 +2043,7 @@ const defaultParserOptions = {
2042
2043
  getNamespace: () => 0,
2043
2044
  isVoidTag: NO,
2044
2045
  isPreTag: NO,
2046
+ isIgnoreNewlineTag: NO,
2045
2047
  isCustomElement: NO,
2046
2048
  onError: defaultOnError,
2047
2049
  onWarn: defaultOnWarn,
@@ -2484,7 +2486,7 @@ function onCloseTag(el, end, isImplied = false) {
2484
2486
  el.innerLoc.end.offset
2485
2487
  );
2486
2488
  }
2487
- const { tag, ns } = el;
2489
+ const { tag, ns, children } = el;
2488
2490
  if (!inVPre) {
2489
2491
  if (tag === "slot") {
2490
2492
  el.tagType = 2;
@@ -2495,7 +2497,13 @@ function onCloseTag(el, end, isImplied = false) {
2495
2497
  }
2496
2498
  }
2497
2499
  if (!tokenizer.inRCDATA) {
2498
- el.children = condenseWhitespace(el.children, el.tag);
2500
+ el.children = condenseWhitespace(children);
2501
+ }
2502
+ if (ns === 0 && currentOptions.isIgnoreNewlineTag(tag)) {
2503
+ const first = children[0];
2504
+ if (first && first.type === 2) {
2505
+ first.content = first.content.replace(/^\r?\n/, "");
2506
+ }
2499
2507
  }
2500
2508
  if (ns === 0 && currentOptions.isPreTag(tag)) {
2501
2509
  inPre--;
@@ -2647,12 +2655,6 @@ function condenseWhitespace(nodes, tag) {
2647
2655
  }
2648
2656
  }
2649
2657
  }
2650
- if (inPre && tag && currentOptions.isPreTag(tag)) {
2651
- const first = nodes[0];
2652
- if (first && first.type === 2) {
2653
- first.content = first.content.replace(/^\r?\n/, "");
2654
- }
2655
- }
2656
2658
  return removedWhitespace ? nodes.filter(Boolean) : nodes;
2657
2659
  }
2658
2660
  function isAllWhitespace(str) {
@@ -3260,10 +3262,8 @@ function createRootCodegen(root, context) {
3260
3262
  }
3261
3263
  } else if (children.length > 1) {
3262
3264
  let patchFlag = 64;
3263
- let patchFlagText = PatchFlagNames[64];
3264
3265
  if (children.filter((c) => c.type !== 3).length === 1) {
3265
3266
  patchFlag |= 2048;
3266
- patchFlagText += `, ${PatchFlagNames[2048]}`;
3267
3267
  }
3268
3268
  root.codegenNode = createVNodeCall(
3269
3269
  context,
@@ -4180,10 +4180,8 @@ function createChildrenCodegenNode(branch, keyIndex, context) {
4180
4180
  return vnodeCall;
4181
4181
  } else {
4182
4182
  let patchFlag = 64;
4183
- let patchFlagText = PatchFlagNames[64];
4184
4183
  if (!branch.isTemplateIf && children.filter((c) => c.type !== 3).length === 1) {
4185
4184
  patchFlag |= 2048;
4186
- patchFlagText += `, ${PatchFlagNames[2048]}`;
4187
4185
  }
4188
4186
  return createVNodeCall(
4189
4187
  context,
@@ -5963,6 +5961,7 @@ const parserOptions = {
5963
5961
  isVoidTag,
5964
5962
  isNativeTag: (tag) => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag),
5965
5963
  isPreTag: (tag) => tag === "pre",
5964
+ isIgnoreNewlineTag: (tag) => tag === "pre" || tag === "textarea",
5966
5965
  decodeEntities: decodeHtmlBrowser ,
5967
5966
  isBuiltInComponent: (tag) => {
5968
5967
  if (tag === "Transition" || tag === "transition") {
@@ -6216,10 +6215,7 @@ const isNonKeyModifier = /* @__PURE__ */ makeMap(
6216
6215
  `stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
6217
6216
  );
6218
6217
  const maybeKeyModifier = /* @__PURE__ */ makeMap("left,right");
6219
- const isKeyboardEvent = /* @__PURE__ */ makeMap(
6220
- `onkeyup,onkeydown,onkeypress`,
6221
- true
6222
- );
6218
+ const isKeyboardEvent = /* @__PURE__ */ makeMap(`onkeyup,onkeydown,onkeypress`);
6223
6219
  const resolveModifiers = (key, modifiers, context, loc) => {
6224
6220
  const keyModifiers = [];
6225
6221
  const nonKeyModifiers = [];
@@ -6237,7 +6233,7 @@ const resolveModifiers = (key, modifiers, context, loc) => {
6237
6233
  } else {
6238
6234
  if (maybeKeyModifier(modifier)) {
6239
6235
  if (isStaticExp(key)) {
6240
- if (isKeyboardEvent(key.content)) {
6236
+ if (isKeyboardEvent(key.content.toLowerCase())) {
6241
6237
  keyModifiers.push(modifier);
6242
6238
  } else {
6243
6239
  nonKeyModifiers.push(modifier);
@@ -6290,7 +6286,7 @@ const transformOn = (dir, node, context) => {
6290
6286
  ]);
6291
6287
  }
6292
6288
  if (keyModifiers.length && // if event name is dynamic, always wrap with keys guard
6293
- (!isStaticExp(key) || isKeyboardEvent(key.content))) {
6289
+ (!isStaticExp(key) || isKeyboardEvent(key.content.toLowerCase()))) {
6294
6290
  handlerExp = createCallExpression(context.helper(V_ON_WITH_KEYS), [
6295
6291
  handlerExp,
6296
6292
  JSON.stringify(keyModifiers)