@vue/runtime-dom 3.2.26 → 3.2.30

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.
@@ -7,7 +7,7 @@ var shared = require('@vue/shared');
7
7
 
8
8
  const svgNS = 'http://www.w3.org/2000/svg';
9
9
  const doc = (typeof document !== 'undefined' ? document : null);
10
- const staticTemplateCache = new Map();
10
+ const templateContainer = doc && doc.createElement('template');
11
11
  const nodeOps = {
12
12
  insert: (child, parent, anchor) => {
13
13
  parent.insertBefore(child, anchor || null);
@@ -61,14 +61,24 @@ const nodeOps = {
61
61
  // Reason: innerHTML.
62
62
  // Static content here can only come from compiled templates.
63
63
  // As long as the user only uses trusted templates, this is safe.
64
- insertStaticContent(content, parent, anchor, isSVG) {
64
+ insertStaticContent(content, parent, anchor, isSVG, start, end) {
65
65
  // <parent> before | first ... last | anchor </parent>
66
66
  const before = anchor ? anchor.previousSibling : parent.lastChild;
67
- let template = staticTemplateCache.get(content);
68
- if (!template) {
69
- const t = doc.createElement('template');
70
- t.innerHTML = isSVG ? `<svg>${content}</svg>` : content;
71
- template = t.content;
67
+ // #5308 can only take cached path if:
68
+ // - has a single root node
69
+ // - nextSibling info is still available
70
+ if (start && (start === end || start.nextSibling)) {
71
+ // cached
72
+ while (true) {
73
+ parent.insertBefore(start.cloneNode(true), anchor);
74
+ if (start === end || !(start = start.nextSibling))
75
+ break;
76
+ }
77
+ }
78
+ else {
79
+ // fresh insert
80
+ templateContainer.innerHTML = isSVG ? `<svg>${content}</svg>` : content;
81
+ const template = templateContainer.content;
72
82
  if (isSVG) {
73
83
  // remove outer svg wrapper
74
84
  const wrapper = template.firstChild;
@@ -77,9 +87,8 @@ const nodeOps = {
77
87
  }
78
88
  template.removeChild(wrapper);
79
89
  }
80
- staticTemplateCache.set(content, template);
90
+ parent.insertBefore(template, anchor);
81
91
  }
82
- parent.insertBefore(template.cloneNode(true), anchor);
83
92
  return [
84
93
  // first
85
94
  before ? before.nextSibling : parent.firstChild,
@@ -371,7 +380,7 @@ function patchStopImmediatePropagation(e, value) {
371
380
  originalStop.call(e);
372
381
  e._stopped = true;
373
382
  };
374
- return value.map(fn => (e) => !e._stopped && fn(e));
383
+ return value.map(fn => (e) => !e._stopped && fn && fn(e));
375
384
  }
376
385
  else {
377
386
  return value;
@@ -7,7 +7,7 @@ var shared = require('@vue/shared');
7
7
 
8
8
  const svgNS = 'http://www.w3.org/2000/svg';
9
9
  const doc = (typeof document !== 'undefined' ? document : null);
10
- const staticTemplateCache = new Map();
10
+ const templateContainer = doc && doc.createElement('template');
11
11
  const nodeOps = {
12
12
  insert: (child, parent, anchor) => {
13
13
  parent.insertBefore(child, anchor || null);
@@ -61,14 +61,24 @@ const nodeOps = {
61
61
  // Reason: innerHTML.
62
62
  // Static content here can only come from compiled templates.
63
63
  // As long as the user only uses trusted templates, this is safe.
64
- insertStaticContent(content, parent, anchor, isSVG) {
64
+ insertStaticContent(content, parent, anchor, isSVG, start, end) {
65
65
  // <parent> before | first ... last | anchor </parent>
66
66
  const before = anchor ? anchor.previousSibling : parent.lastChild;
67
- let template = staticTemplateCache.get(content);
68
- if (!template) {
69
- const t = doc.createElement('template');
70
- t.innerHTML = isSVG ? `<svg>${content}</svg>` : content;
71
- template = t.content;
67
+ // #5308 can only take cached path if:
68
+ // - has a single root node
69
+ // - nextSibling info is still available
70
+ if (start && (start === end || start.nextSibling)) {
71
+ // cached
72
+ while (true) {
73
+ parent.insertBefore(start.cloneNode(true), anchor);
74
+ if (start === end || !(start = start.nextSibling))
75
+ break;
76
+ }
77
+ }
78
+ else {
79
+ // fresh insert
80
+ templateContainer.innerHTML = isSVG ? `<svg>${content}</svg>` : content;
81
+ const template = templateContainer.content;
72
82
  if (isSVG) {
73
83
  // remove outer svg wrapper
74
84
  const wrapper = template.firstChild;
@@ -77,9 +87,8 @@ const nodeOps = {
77
87
  }
78
88
  template.removeChild(wrapper);
79
89
  }
80
- staticTemplateCache.set(content, template);
90
+ parent.insertBefore(template, anchor);
81
91
  }
82
- parent.insertBefore(template.cloneNode(true), anchor);
83
92
  return [
84
93
  // first
85
94
  before ? before.nextSibling : parent.firstChild,
@@ -367,7 +376,7 @@ function patchStopImmediatePropagation(e, value) {
367
376
  originalStop.call(e);
368
377
  e._stopped = true;
369
378
  };
370
- return value.map(fn => (e) => !e._stopped && fn(e));
379
+ return value.map(fn => (e) => !e._stopped && fn && fn(e));
371
380
  }
372
381
  else {
373
382
  return value;
@@ -1480,6 +1480,8 @@ type ReservedProps = {
1480
1480
  | string
1481
1481
  | RuntimeCore.Ref
1482
1482
  | ((ref: Element | RuntimeCore.ComponentPublicInstance | null) => void)
1483
+ ref_for?: boolean
1484
+ ref_key?: string
1483
1485
  }
1484
1486
 
1485
1487
  type ElementAttrs<T> = T & ReservedProps