@vue/runtime-dom 3.1.0 → 3.1.4

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,8 +7,6 @@ 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
- let tempContainer;
11
- let tempSVGContainer;
12
10
  const nodeOps = {
13
11
  insert: (child, parent, anchor) => {
14
12
  parent.insertBefore(child, anchor || null);
@@ -59,24 +57,60 @@ const nodeOps = {
59
57
  return cloned;
60
58
  },
61
59
  // __UNSAFE__
62
- // Reason: innerHTML.
60
+ // Reason: insertAdjacentHTML.
63
61
  // Static content here can only come from compiled templates.
64
62
  // As long as the user only uses trusted templates, this is safe.
65
- insertStaticContent(content, parent, anchor, isSVG) {
66
- const temp = isSVG
67
- ? tempSVGContainer ||
68
- (tempSVGContainer = doc.createElementNS(svgNS, 'svg'))
69
- : tempContainer || (tempContainer = doc.createElement('div'));
70
- temp.innerHTML = content;
71
- const first = temp.firstChild;
72
- let node = first;
73
- let last = node;
74
- while (node) {
75
- last = node;
76
- nodeOps.insert(node, parent, anchor);
77
- node = temp.firstChild;
78
- }
79
- return [first, last];
63
+ insertStaticContent(content, parent, anchor, isSVG, cached) {
64
+ if (cached) {
65
+ let first;
66
+ let last;
67
+ let i = 0;
68
+ let l = cached.length;
69
+ for (; i < l; i++) {
70
+ const node = cached[i].cloneNode(true);
71
+ if (i === 0)
72
+ first = node;
73
+ if (i === l - 1)
74
+ last = node;
75
+ parent.insertBefore(node, anchor);
76
+ }
77
+ return [first, last];
78
+ }
79
+ // <parent> before | first ... last | anchor </parent>
80
+ const before = anchor ? anchor.previousSibling : parent.lastChild;
81
+ if (anchor) {
82
+ let insertionPoint;
83
+ let usingTempInsertionPoint = false;
84
+ if (anchor instanceof Element) {
85
+ insertionPoint = anchor;
86
+ }
87
+ else {
88
+ // insertAdjacentHTML only works for elements but the anchor is not an
89
+ // element...
90
+ usingTempInsertionPoint = true;
91
+ insertionPoint = isSVG
92
+ ? doc.createElementNS(svgNS, 'g')
93
+ : doc.createElement('div');
94
+ parent.insertBefore(insertionPoint, anchor);
95
+ }
96
+ insertionPoint.insertAdjacentHTML('beforebegin', content);
97
+ if (usingTempInsertionPoint) {
98
+ parent.removeChild(insertionPoint);
99
+ }
100
+ }
101
+ else {
102
+ parent.insertAdjacentHTML('beforeend', content);
103
+ }
104
+ let first = before ? before.nextSibling : parent.firstChild;
105
+ const last = anchor ? anchor.previousSibling : parent.lastChild;
106
+ const ret = [];
107
+ while (first) {
108
+ ret.push(first);
109
+ if (first === last)
110
+ break;
111
+ first = first.nextSibling;
112
+ }
113
+ return ret;
80
114
  }
81
115
  };
82
116
 
@@ -7,8 +7,6 @@ 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
- let tempContainer;
11
- let tempSVGContainer;
12
10
  const nodeOps = {
13
11
  insert: (child, parent, anchor) => {
14
12
  parent.insertBefore(child, anchor || null);
@@ -59,24 +57,60 @@ const nodeOps = {
59
57
  return cloned;
60
58
  },
61
59
  // __UNSAFE__
62
- // Reason: innerHTML.
60
+ // Reason: insertAdjacentHTML.
63
61
  // Static content here can only come from compiled templates.
64
62
  // As long as the user only uses trusted templates, this is safe.
65
- insertStaticContent(content, parent, anchor, isSVG) {
66
- const temp = isSVG
67
- ? tempSVGContainer ||
68
- (tempSVGContainer = doc.createElementNS(svgNS, 'svg'))
69
- : tempContainer || (tempContainer = doc.createElement('div'));
70
- temp.innerHTML = content;
71
- const first = temp.firstChild;
72
- let node = first;
73
- let last = node;
74
- while (node) {
75
- last = node;
76
- nodeOps.insert(node, parent, anchor);
77
- node = temp.firstChild;
78
- }
79
- return [first, last];
63
+ insertStaticContent(content, parent, anchor, isSVG, cached) {
64
+ if (cached) {
65
+ let first;
66
+ let last;
67
+ let i = 0;
68
+ let l = cached.length;
69
+ for (; i < l; i++) {
70
+ const node = cached[i].cloneNode(true);
71
+ if (i === 0)
72
+ first = node;
73
+ if (i === l - 1)
74
+ last = node;
75
+ parent.insertBefore(node, anchor);
76
+ }
77
+ return [first, last];
78
+ }
79
+ // <parent> before | first ... last | anchor </parent>
80
+ const before = anchor ? anchor.previousSibling : parent.lastChild;
81
+ if (anchor) {
82
+ let insertionPoint;
83
+ let usingTempInsertionPoint = false;
84
+ if (anchor instanceof Element) {
85
+ insertionPoint = anchor;
86
+ }
87
+ else {
88
+ // insertAdjacentHTML only works for elements but the anchor is not an
89
+ // element...
90
+ usingTempInsertionPoint = true;
91
+ insertionPoint = isSVG
92
+ ? doc.createElementNS(svgNS, 'g')
93
+ : doc.createElement('div');
94
+ parent.insertBefore(insertionPoint, anchor);
95
+ }
96
+ insertionPoint.insertAdjacentHTML('beforebegin', content);
97
+ if (usingTempInsertionPoint) {
98
+ parent.removeChild(insertionPoint);
99
+ }
100
+ }
101
+ else {
102
+ parent.insertAdjacentHTML('beforeend', content);
103
+ }
104
+ let first = before ? before.nextSibling : parent.firstChild;
105
+ const last = anchor ? anchor.previousSibling : parent.lastChild;
106
+ const ret = [];
107
+ while (first) {
108
+ ret.push(first);
109
+ if (first === last)
110
+ break;
111
+ first = first.nextSibling;
112
+ }
113
+ return ret;
80
114
  }
81
115
  };
82
116
 
@@ -1389,10 +1389,8 @@ export interface Events {
1389
1389
  onTransitionstart: TransitionEvent
1390
1390
  }
1391
1391
 
1392
- type StringKeyOf<T> = Extract<keyof T, string>
1393
-
1394
1392
  type EventHandlers<E> = {
1395
- [K in StringKeyOf<E>]?: E[K] extends Function ? E[K] : (payload: E[K]) => void
1393
+ [K in keyof E]?: E[K] extends Function ? E[K] : (payload: E[K]) => void
1396
1394
  }
1397
1395
 
1398
1396
  // use namespace import to avoid collision with generated types which use
@@ -1410,7 +1408,7 @@ type ReservedProps = {
1410
1408
  type ElementAttrs<T> = T & ReservedProps
1411
1409
 
1412
1410
  type NativeElements = {
1413
- [K in StringKeyOf<IntrinsicElementAttributes>]: ElementAttrs<
1411
+ [K in keyof IntrinsicElementAttributes]: ElementAttrs<
1414
1412
  IntrinsicElementAttributes[K]
1415
1413
  >
1416
1414
  }