@vue/runtime-dom 3.2.40 → 3.2.41

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.
@@ -5,1627 +5,1611 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var runtimeCore = require('@vue/runtime-core');
6
6
  var shared = require('@vue/shared');
7
7
 
8
- const svgNS = 'http://www.w3.org/2000/svg';
9
- const doc = (typeof document !== 'undefined' ? document : null);
10
- const templateContainer = doc && /*#__PURE__*/ doc.createElement('template');
11
- const nodeOps = {
12
- insert: (child, parent, anchor) => {
13
- parent.insertBefore(child, anchor || null);
14
- },
15
- remove: child => {
16
- const parent = child.parentNode;
17
- if (parent) {
18
- parent.removeChild(child);
19
- }
20
- },
21
- createElement: (tag, isSVG, is, props) => {
22
- const el = isSVG
23
- ? doc.createElementNS(svgNS, tag)
24
- : doc.createElement(tag, is ? { is } : undefined);
25
- if (tag === 'select' && props && props.multiple != null) {
26
- el.setAttribute('multiple', props.multiple);
27
- }
28
- return el;
29
- },
30
- createText: text => doc.createTextNode(text),
31
- createComment: text => doc.createComment(text),
32
- setText: (node, text) => {
33
- node.nodeValue = text;
34
- },
35
- setElementText: (el, text) => {
36
- el.textContent = text;
37
- },
38
- parentNode: node => node.parentNode,
39
- nextSibling: node => node.nextSibling,
40
- querySelector: selector => doc.querySelector(selector),
41
- setScopeId(el, id) {
42
- el.setAttribute(id, '');
43
- },
44
- // __UNSAFE__
45
- // Reason: innerHTML.
46
- // Static content here can only come from compiled templates.
47
- // As long as the user only uses trusted templates, this is safe.
48
- insertStaticContent(content, parent, anchor, isSVG, start, end) {
49
- // <parent> before | first ... last | anchor </parent>
50
- const before = anchor ? anchor.previousSibling : parent.lastChild;
51
- // #5308 can only take cached path if:
52
- // - has a single root node
53
- // - nextSibling info is still available
54
- if (start && (start === end || start.nextSibling)) {
55
- // cached
56
- while (true) {
57
- parent.insertBefore(start.cloneNode(true), anchor);
58
- if (start === end || !(start = start.nextSibling))
59
- break;
60
- }
61
- }
62
- else {
63
- // fresh insert
64
- templateContainer.innerHTML = isSVG ? `<svg>${content}</svg>` : content;
65
- const template = templateContainer.content;
66
- if (isSVG) {
67
- // remove outer svg wrapper
68
- const wrapper = template.firstChild;
69
- while (wrapper.firstChild) {
70
- template.appendChild(wrapper.firstChild);
71
- }
72
- template.removeChild(wrapper);
73
- }
74
- parent.insertBefore(template, anchor);
75
- }
76
- return [
77
- // first
78
- before ? before.nextSibling : parent.firstChild,
79
- // last
80
- anchor ? anchor.previousSibling : parent.lastChild
81
- ];
82
- }
8
+ const svgNS = 'http://www.w3.org/2000/svg';
9
+ const doc = (typeof document !== 'undefined' ? document : null);
10
+ const templateContainer = doc && /*#__PURE__*/ doc.createElement('template');
11
+ const nodeOps = {
12
+ insert: (child, parent, anchor) => {
13
+ parent.insertBefore(child, anchor || null);
14
+ },
15
+ remove: child => {
16
+ const parent = child.parentNode;
17
+ if (parent) {
18
+ parent.removeChild(child);
19
+ }
20
+ },
21
+ createElement: (tag, isSVG, is, props) => {
22
+ const el = isSVG
23
+ ? doc.createElementNS(svgNS, tag)
24
+ : doc.createElement(tag, is ? { is } : undefined);
25
+ if (tag === 'select' && props && props.multiple != null) {
26
+ el.setAttribute('multiple', props.multiple);
27
+ }
28
+ return el;
29
+ },
30
+ createText: text => doc.createTextNode(text),
31
+ createComment: text => doc.createComment(text),
32
+ setText: (node, text) => {
33
+ node.nodeValue = text;
34
+ },
35
+ setElementText: (el, text) => {
36
+ el.textContent = text;
37
+ },
38
+ parentNode: node => node.parentNode,
39
+ nextSibling: node => node.nextSibling,
40
+ querySelector: selector => doc.querySelector(selector),
41
+ setScopeId(el, id) {
42
+ el.setAttribute(id, '');
43
+ },
44
+ // __UNSAFE__
45
+ // Reason: innerHTML.
46
+ // Static content here can only come from compiled templates.
47
+ // As long as the user only uses trusted templates, this is safe.
48
+ insertStaticContent(content, parent, anchor, isSVG, start, end) {
49
+ // <parent> before | first ... last | anchor </parent>
50
+ const before = anchor ? anchor.previousSibling : parent.lastChild;
51
+ // #5308 can only take cached path if:
52
+ // - has a single root node
53
+ // - nextSibling info is still available
54
+ if (start && (start === end || start.nextSibling)) {
55
+ // cached
56
+ while (true) {
57
+ parent.insertBefore(start.cloneNode(true), anchor);
58
+ if (start === end || !(start = start.nextSibling))
59
+ break;
60
+ }
61
+ }
62
+ else {
63
+ // fresh insert
64
+ templateContainer.innerHTML = isSVG ? `<svg>${content}</svg>` : content;
65
+ const template = templateContainer.content;
66
+ if (isSVG) {
67
+ // remove outer svg wrapper
68
+ const wrapper = template.firstChild;
69
+ while (wrapper.firstChild) {
70
+ template.appendChild(wrapper.firstChild);
71
+ }
72
+ template.removeChild(wrapper);
73
+ }
74
+ parent.insertBefore(template, anchor);
75
+ }
76
+ return [
77
+ // first
78
+ before ? before.nextSibling : parent.firstChild,
79
+ // last
80
+ anchor ? anchor.previousSibling : parent.lastChild
81
+ ];
82
+ }
83
83
  };
84
84
 
85
- // compiler should normalize class + :class bindings on the same element
86
- // into a single binding ['staticClass', dynamic]
87
- function patchClass(el, value, isSVG) {
88
- // directly setting className should be faster than setAttribute in theory
89
- // if this is an element during a transition, take the temporary transition
90
- // classes into account.
91
- const transitionClasses = el._vtc;
92
- if (transitionClasses) {
93
- value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(' ');
94
- }
95
- if (value == null) {
96
- el.removeAttribute('class');
97
- }
98
- else if (isSVG) {
99
- el.setAttribute('class', value);
100
- }
101
- else {
102
- el.className = value;
103
- }
85
+ // compiler should normalize class + :class bindings on the same element
86
+ // into a single binding ['staticClass', dynamic]
87
+ function patchClass(el, value, isSVG) {
88
+ // directly setting className should be faster than setAttribute in theory
89
+ // if this is an element during a transition, take the temporary transition
90
+ // classes into account.
91
+ const transitionClasses = el._vtc;
92
+ if (transitionClasses) {
93
+ value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(' ');
94
+ }
95
+ if (value == null) {
96
+ el.removeAttribute('class');
97
+ }
98
+ else if (isSVG) {
99
+ el.setAttribute('class', value);
100
+ }
101
+ else {
102
+ el.className = value;
103
+ }
104
104
  }
105
105
 
106
- function patchStyle(el, prev, next) {
107
- const style = el.style;
108
- const isCssString = shared.isString(next);
109
- if (next && !isCssString) {
110
- for (const key in next) {
111
- setStyle(style, key, next[key]);
112
- }
113
- if (prev && !shared.isString(prev)) {
114
- for (const key in prev) {
115
- if (next[key] == null) {
116
- setStyle(style, key, '');
117
- }
118
- }
119
- }
120
- }
121
- else {
122
- const currentDisplay = style.display;
123
- if (isCssString) {
124
- if (prev !== next) {
125
- style.cssText = next;
126
- }
127
- }
128
- else if (prev) {
129
- el.removeAttribute('style');
130
- }
131
- // indicates that the `display` of the element is controlled by `v-show`,
132
- // so we always keep the current `display` value regardless of the `style`
133
- // value, thus handing over control to `v-show`.
134
- if ('_vod' in el) {
135
- style.display = currentDisplay;
136
- }
137
- }
138
- }
139
- const importantRE = /\s*!important$/;
140
- function setStyle(style, name, val) {
141
- if (shared.isArray(val)) {
142
- val.forEach(v => setStyle(style, name, v));
143
- }
144
- else {
145
- if (val == null)
146
- val = '';
147
- if (name.startsWith('--')) {
148
- // custom property definition
149
- style.setProperty(name, val);
150
- }
151
- else {
152
- const prefixed = autoPrefix(style, name);
153
- if (importantRE.test(val)) {
154
- // !important
155
- style.setProperty(shared.hyphenate(prefixed), val.replace(importantRE, ''), 'important');
156
- }
157
- else {
158
- style[prefixed] = val;
159
- }
160
- }
161
- }
162
- }
163
- const prefixes = ['Webkit', 'Moz', 'ms'];
164
- const prefixCache = {};
165
- function autoPrefix(style, rawName) {
166
- const cached = prefixCache[rawName];
167
- if (cached) {
168
- return cached;
169
- }
170
- let name = runtimeCore.camelize(rawName);
171
- if (name !== 'filter' && name in style) {
172
- return (prefixCache[rawName] = name);
173
- }
174
- name = shared.capitalize(name);
175
- for (let i = 0; i < prefixes.length; i++) {
176
- const prefixed = prefixes[i] + name;
177
- if (prefixed in style) {
178
- return (prefixCache[rawName] = prefixed);
179
- }
180
- }
181
- return rawName;
106
+ function patchStyle(el, prev, next) {
107
+ const style = el.style;
108
+ const isCssString = shared.isString(next);
109
+ if (next && !isCssString) {
110
+ for (const key in next) {
111
+ setStyle(style, key, next[key]);
112
+ }
113
+ if (prev && !shared.isString(prev)) {
114
+ for (const key in prev) {
115
+ if (next[key] == null) {
116
+ setStyle(style, key, '');
117
+ }
118
+ }
119
+ }
120
+ }
121
+ else {
122
+ const currentDisplay = style.display;
123
+ if (isCssString) {
124
+ if (prev !== next) {
125
+ style.cssText = next;
126
+ }
127
+ }
128
+ else if (prev) {
129
+ el.removeAttribute('style');
130
+ }
131
+ // indicates that the `display` of the element is controlled by `v-show`,
132
+ // so we always keep the current `display` value regardless of the `style`
133
+ // value, thus handing over control to `v-show`.
134
+ if ('_vod' in el) {
135
+ style.display = currentDisplay;
136
+ }
137
+ }
138
+ }
139
+ const importantRE = /\s*!important$/;
140
+ function setStyle(style, name, val) {
141
+ if (shared.isArray(val)) {
142
+ val.forEach(v => setStyle(style, name, v));
143
+ }
144
+ else {
145
+ if (val == null)
146
+ val = '';
147
+ if (name.startsWith('--')) {
148
+ // custom property definition
149
+ style.setProperty(name, val);
150
+ }
151
+ else {
152
+ const prefixed = autoPrefix(style, name);
153
+ if (importantRE.test(val)) {
154
+ // !important
155
+ style.setProperty(shared.hyphenate(prefixed), val.replace(importantRE, ''), 'important');
156
+ }
157
+ else {
158
+ style[prefixed] = val;
159
+ }
160
+ }
161
+ }
162
+ }
163
+ const prefixes = ['Webkit', 'Moz', 'ms'];
164
+ const prefixCache = {};
165
+ function autoPrefix(style, rawName) {
166
+ const cached = prefixCache[rawName];
167
+ if (cached) {
168
+ return cached;
169
+ }
170
+ let name = runtimeCore.camelize(rawName);
171
+ if (name !== 'filter' && name in style) {
172
+ return (prefixCache[rawName] = name);
173
+ }
174
+ name = shared.capitalize(name);
175
+ for (let i = 0; i < prefixes.length; i++) {
176
+ const prefixed = prefixes[i] + name;
177
+ if (prefixed in style) {
178
+ return (prefixCache[rawName] = prefixed);
179
+ }
180
+ }
181
+ return rawName;
182
182
  }
183
183
 
184
- const xlinkNS = 'http://www.w3.org/1999/xlink';
185
- function patchAttr(el, key, value, isSVG, instance) {
186
- if (isSVG && key.startsWith('xlink:')) {
187
- if (value == null) {
188
- el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
189
- }
190
- else {
191
- el.setAttributeNS(xlinkNS, key, value);
192
- }
193
- }
194
- else {
195
- // note we are only checking boolean attributes that don't have a
196
- // corresponding dom prop of the same name here.
197
- const isBoolean = shared.isSpecialBooleanAttr(key);
198
- if (value == null || (isBoolean && !shared.includeBooleanAttr(value))) {
199
- el.removeAttribute(key);
200
- }
201
- else {
202
- el.setAttribute(key, isBoolean ? '' : value);
203
- }
204
- }
184
+ const xlinkNS = 'http://www.w3.org/1999/xlink';
185
+ function patchAttr(el, key, value, isSVG, instance) {
186
+ if (isSVG && key.startsWith('xlink:')) {
187
+ if (value == null) {
188
+ el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
189
+ }
190
+ else {
191
+ el.setAttributeNS(xlinkNS, key, value);
192
+ }
193
+ }
194
+ else {
195
+ // note we are only checking boolean attributes that don't have a
196
+ // corresponding dom prop of the same name here.
197
+ const isBoolean = shared.isSpecialBooleanAttr(key);
198
+ if (value == null || (isBoolean && !shared.includeBooleanAttr(value))) {
199
+ el.removeAttribute(key);
200
+ }
201
+ else {
202
+ el.setAttribute(key, isBoolean ? '' : value);
203
+ }
204
+ }
205
205
  }
206
206
 
207
- // __UNSAFE__
208
- // functions. The user is responsible for using them with only trusted content.
209
- function patchDOMProp(el, key, value,
210
- // the following args are passed only due to potential innerHTML/textContent
211
- // overriding existing VNodes, in which case the old tree must be properly
212
- // unmounted.
213
- prevChildren, parentComponent, parentSuspense, unmountChildren) {
214
- if (key === 'innerHTML' || key === 'textContent') {
215
- if (prevChildren) {
216
- unmountChildren(prevChildren, parentComponent, parentSuspense);
217
- }
218
- el[key] = value == null ? '' : value;
219
- return;
220
- }
221
- if (key === 'value' &&
222
- el.tagName !== 'PROGRESS' &&
223
- // custom elements may use _value internally
224
- !el.tagName.includes('-')) {
225
- // store value as _value as well since
226
- // non-string values will be stringified.
227
- el._value = value;
228
- const newValue = value == null ? '' : value;
229
- if (el.value !== newValue ||
230
- // #4956: always set for OPTION elements because its value falls back to
231
- // textContent if no value attribute is present. And setting .value for
232
- // OPTION has no side effect
233
- el.tagName === 'OPTION') {
234
- el.value = newValue;
235
- }
236
- if (value == null) {
237
- el.removeAttribute(key);
238
- }
239
- return;
240
- }
241
- let needRemove = false;
242
- if (value === '' || value == null) {
243
- const type = typeof el[key];
244
- if (type === 'boolean') {
245
- // e.g. <select multiple> compiles to { multiple: '' }
246
- value = shared.includeBooleanAttr(value);
247
- }
248
- else if (value == null && type === 'string') {
249
- // e.g. <div :id="null">
250
- value = '';
251
- needRemove = true;
252
- }
253
- else if (type === 'number') {
254
- // e.g. <img :width="null">
255
- value = 0;
256
- needRemove = true;
257
- }
258
- }
259
- // some properties perform value validation and throw,
260
- // some properties has getter, no setter, will error in 'use strict'
261
- // eg. <select :type="null"></select> <select :willValidate="null"></select>
262
- try {
263
- el[key] = value;
264
- }
265
- catch (e) {
266
- // do not warn if value is auto-coerced from nullish values
267
- if (!needRemove) {
268
- runtimeCore.warn(`Failed setting prop "${key}" on <${el.tagName.toLowerCase()}>: ` +
269
- `value ${value} is invalid.`, e);
270
- }
271
- }
272
- needRemove && el.removeAttribute(key);
207
+ // __UNSAFE__
208
+ // functions. The user is responsible for using them with only trusted content.
209
+ function patchDOMProp(el, key, value,
210
+ // the following args are passed only due to potential innerHTML/textContent
211
+ // overriding existing VNodes, in which case the old tree must be properly
212
+ // unmounted.
213
+ prevChildren, parentComponent, parentSuspense, unmountChildren) {
214
+ if (key === 'innerHTML' || key === 'textContent') {
215
+ if (prevChildren) {
216
+ unmountChildren(prevChildren, parentComponent, parentSuspense);
217
+ }
218
+ el[key] = value == null ? '' : value;
219
+ return;
220
+ }
221
+ if (key === 'value' &&
222
+ el.tagName !== 'PROGRESS' &&
223
+ // custom elements may use _value internally
224
+ !el.tagName.includes('-')) {
225
+ // store value as _value as well since
226
+ // non-string values will be stringified.
227
+ el._value = value;
228
+ const newValue = value == null ? '' : value;
229
+ if (el.value !== newValue ||
230
+ // #4956: always set for OPTION elements because its value falls back to
231
+ // textContent if no value attribute is present. And setting .value for
232
+ // OPTION has no side effect
233
+ el.tagName === 'OPTION') {
234
+ el.value = newValue;
235
+ }
236
+ if (value == null) {
237
+ el.removeAttribute(key);
238
+ }
239
+ return;
240
+ }
241
+ let needRemove = false;
242
+ if (value === '' || value == null) {
243
+ const type = typeof el[key];
244
+ if (type === 'boolean') {
245
+ // e.g. <select multiple> compiles to { multiple: '' }
246
+ value = shared.includeBooleanAttr(value);
247
+ }
248
+ else if (value == null && type === 'string') {
249
+ // e.g. <div :id="null">
250
+ value = '';
251
+ needRemove = true;
252
+ }
253
+ else if (type === 'number') {
254
+ // e.g. <img :width="null">
255
+ value = 0;
256
+ needRemove = true;
257
+ }
258
+ }
259
+ // some properties perform value validation and throw,
260
+ // some properties has getter, no setter, will error in 'use strict'
261
+ // eg. <select :type="null"></select> <select :willValidate="null"></select>
262
+ try {
263
+ el[key] = value;
264
+ }
265
+ catch (e) {
266
+ // do not warn if value is auto-coerced from nullish values
267
+ if (!needRemove) {
268
+ runtimeCore.warn(`Failed setting prop "${key}" on <${el.tagName.toLowerCase()}>: ` +
269
+ `value ${value} is invalid.`, e);
270
+ }
271
+ }
272
+ needRemove && el.removeAttribute(key);
273
273
  }
274
274
 
275
- // Async edge case fix requires storing an event listener's attach timestamp.
276
- const [_getNow, skipTimestampCheck] = /*#__PURE__*/ (() => {
277
- let _getNow = Date.now;
278
- let skipTimestampCheck = false;
279
- if (typeof window !== 'undefined') {
280
- // Determine what event timestamp the browser is using. Annoyingly, the
281
- // timestamp can either be hi-res (relative to page load) or low-res
282
- // (relative to UNIX epoch), so in order to compare time we have to use the
283
- // same timestamp type when saving the flush timestamp.
284
- if (Date.now() > document.createEvent('Event').timeStamp) {
285
- // if the low-res timestamp which is bigger than the event timestamp
286
- // (which is evaluated AFTER) it means the event is using a hi-res timestamp,
287
- // and we need to use the hi-res version for event listeners as well.
288
- _getNow = performance.now.bind(performance);
289
- }
290
- // #3485: Firefox <= 53 has incorrect Event.timeStamp implementation
291
- // and does not fire microtasks in between event propagation, so safe to exclude.
292
- const ffMatch = navigator.userAgent.match(/firefox\/(\d+)/i);
293
- skipTimestampCheck = !!(ffMatch && Number(ffMatch[1]) <= 53);
294
- }
295
- return [_getNow, skipTimestampCheck];
296
- })();
297
- // To avoid the overhead of repeatedly calling performance.now(), we cache
298
- // and use the same timestamp for all event listeners attached in the same tick.
299
- let cachedNow = 0;
300
- const p = /*#__PURE__*/ Promise.resolve();
301
- const reset = () => {
302
- cachedNow = 0;
303
- };
304
- const getNow = () => cachedNow || (p.then(reset), (cachedNow = _getNow()));
305
- function addEventListener(el, event, handler, options) {
306
- el.addEventListener(event, handler, options);
307
- }
308
- function removeEventListener(el, event, handler, options) {
309
- el.removeEventListener(event, handler, options);
310
- }
311
- function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
312
- // vei = vue event invokers
313
- const invokers = el._vei || (el._vei = {});
314
- const existingInvoker = invokers[rawName];
315
- if (nextValue && existingInvoker) {
316
- // patch
317
- existingInvoker.value = nextValue;
318
- }
319
- else {
320
- const [name, options] = parseName(rawName);
321
- if (nextValue) {
322
- // add
323
- const invoker = (invokers[rawName] = createInvoker(nextValue, instance));
324
- addEventListener(el, name, invoker, options);
325
- }
326
- else if (existingInvoker) {
327
- // remove
328
- removeEventListener(el, name, existingInvoker, options);
329
- invokers[rawName] = undefined;
330
- }
331
- }
332
- }
333
- const optionsModifierRE = /(?:Once|Passive|Capture)$/;
334
- function parseName(name) {
335
- let options;
336
- if (optionsModifierRE.test(name)) {
337
- options = {};
338
- let m;
339
- while ((m = name.match(optionsModifierRE))) {
340
- name = name.slice(0, name.length - m[0].length);
341
- options[m[0].toLowerCase()] = true;
342
- }
343
- }
344
- const event = name[2] === ':' ? name.slice(3) : shared.hyphenate(name.slice(2));
345
- return [event, options];
346
- }
347
- function createInvoker(initialValue, instance) {
348
- const invoker = (e) => {
349
- // async edge case #6566: inner click event triggers patch, event handler
350
- // attached to outer element during patch, and triggered again. This
351
- // happens because browsers fire microtask ticks between event propagation.
352
- // the solution is simple: we save the timestamp when a handler is attached,
353
- // and the handler would only fire if the event passed to it was fired
354
- // AFTER it was attached.
355
- const timeStamp = e.timeStamp || _getNow();
356
- if (skipTimestampCheck || timeStamp >= invoker.attached - 1) {
357
- runtimeCore.callWithAsyncErrorHandling(patchStopImmediatePropagation(e, invoker.value), instance, 5 /* ErrorCodes.NATIVE_EVENT_HANDLER */, [e]);
358
- }
359
- };
360
- invoker.value = initialValue;
361
- invoker.attached = getNow();
362
- return invoker;
363
- }
364
- function patchStopImmediatePropagation(e, value) {
365
- if (shared.isArray(value)) {
366
- const originalStop = e.stopImmediatePropagation;
367
- e.stopImmediatePropagation = () => {
368
- originalStop.call(e);
369
- e._stopped = true;
370
- };
371
- return value.map(fn => (e) => !e._stopped && fn && fn(e));
372
- }
373
- else {
374
- return value;
375
- }
275
+ function addEventListener(el, event, handler, options) {
276
+ el.addEventListener(event, handler, options);
277
+ }
278
+ function removeEventListener(el, event, handler, options) {
279
+ el.removeEventListener(event, handler, options);
280
+ }
281
+ function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
282
+ // vei = vue event invokers
283
+ const invokers = el._vei || (el._vei = {});
284
+ const existingInvoker = invokers[rawName];
285
+ if (nextValue && existingInvoker) {
286
+ // patch
287
+ existingInvoker.value = nextValue;
288
+ }
289
+ else {
290
+ const [name, options] = parseName(rawName);
291
+ if (nextValue) {
292
+ // add
293
+ const invoker = (invokers[rawName] = createInvoker(nextValue, instance));
294
+ addEventListener(el, name, invoker, options);
295
+ }
296
+ else if (existingInvoker) {
297
+ // remove
298
+ removeEventListener(el, name, existingInvoker, options);
299
+ invokers[rawName] = undefined;
300
+ }
301
+ }
302
+ }
303
+ const optionsModifierRE = /(?:Once|Passive|Capture)$/;
304
+ function parseName(name) {
305
+ let options;
306
+ if (optionsModifierRE.test(name)) {
307
+ options = {};
308
+ let m;
309
+ while ((m = name.match(optionsModifierRE))) {
310
+ name = name.slice(0, name.length - m[0].length);
311
+ options[m[0].toLowerCase()] = true;
312
+ }
313
+ }
314
+ const event = name[2] === ':' ? name.slice(3) : shared.hyphenate(name.slice(2));
315
+ return [event, options];
316
+ }
317
+ // To avoid the overhead of repeatedly calling Date.now(), we cache
318
+ // and use the same timestamp for all event listeners attached in the same tick.
319
+ let cachedNow = 0;
320
+ const p = /*#__PURE__*/ Promise.resolve();
321
+ const getNow = () => cachedNow || (p.then(() => (cachedNow = 0)), (cachedNow = Date.now()));
322
+ function createInvoker(initialValue, instance) {
323
+ const invoker = (e) => {
324
+ // async edge case vuejs/vue#6566
325
+ // inner click event triggers patch, event handler
326
+ // attached to outer element during patch, and triggered again. This
327
+ // happens because browsers fire microtask ticks between event propagation.
328
+ // this no longer happens for templates in Vue 3, but could still be
329
+ // theoretically possible for hand-written render functions.
330
+ // the solution: we save the timestamp when a handler is attached,
331
+ // and also attach the timestamp to any event that was handled by vue
332
+ // for the first time (to avoid inconsistent event timestamp implementations
333
+ // or events fired from iframes, e.g. #2513)
334
+ // The handler would only fire if the event passed to it was fired
335
+ // AFTER it was attached.
336
+ if (!e._vts) {
337
+ e._vts = Date.now();
338
+ }
339
+ else if (e._vts <= invoker.attached) {
340
+ return;
341
+ }
342
+ runtimeCore.callWithAsyncErrorHandling(patchStopImmediatePropagation(e, invoker.value), instance, 5 /* ErrorCodes.NATIVE_EVENT_HANDLER */, [e]);
343
+ };
344
+ invoker.value = initialValue;
345
+ invoker.attached = getNow();
346
+ return invoker;
347
+ }
348
+ function patchStopImmediatePropagation(e, value) {
349
+ if (shared.isArray(value)) {
350
+ const originalStop = e.stopImmediatePropagation;
351
+ e.stopImmediatePropagation = () => {
352
+ originalStop.call(e);
353
+ e._stopped = true;
354
+ };
355
+ return value.map(fn => (e) => !e._stopped && fn && fn(e));
356
+ }
357
+ else {
358
+ return value;
359
+ }
376
360
  }
377
361
 
378
- const nativeOnRE = /^on[a-z]/;
379
- const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
380
- if (key === 'class') {
381
- patchClass(el, nextValue, isSVG);
382
- }
383
- else if (key === 'style') {
384
- patchStyle(el, prevValue, nextValue);
385
- }
386
- else if (shared.isOn(key)) {
387
- // ignore v-model listeners
388
- if (!shared.isModelListener(key)) {
389
- patchEvent(el, key, prevValue, nextValue, parentComponent);
390
- }
391
- }
392
- else if (key[0] === '.'
393
- ? ((key = key.slice(1)), true)
394
- : key[0] === '^'
395
- ? ((key = key.slice(1)), false)
396
- : shouldSetAsProp(el, key, nextValue, isSVG)) {
397
- patchDOMProp(el, key, nextValue, prevChildren, parentComponent, parentSuspense, unmountChildren);
398
- }
399
- else {
400
- // special case for <input v-model type="checkbox"> with
401
- // :true-value & :false-value
402
- // store value as dom properties since non-string values will be
403
- // stringified.
404
- if (key === 'true-value') {
405
- el._trueValue = nextValue;
406
- }
407
- else if (key === 'false-value') {
408
- el._falseValue = nextValue;
409
- }
410
- patchAttr(el, key, nextValue, isSVG);
411
- }
412
- };
413
- function shouldSetAsProp(el, key, value, isSVG) {
414
- if (isSVG) {
415
- // most keys must be set as attribute on svg elements to work
416
- // ...except innerHTML & textContent
417
- if (key === 'innerHTML' || key === 'textContent') {
418
- return true;
419
- }
420
- // or native onclick with function values
421
- if (key in el && nativeOnRE.test(key) && shared.isFunction(value)) {
422
- return true;
423
- }
424
- return false;
425
- }
426
- // these are enumerated attrs, however their corresponding DOM properties
427
- // are actually booleans - this leads to setting it with a string "false"
428
- // value leading it to be coerced to `true`, so we need to always treat
429
- // them as attributes.
430
- // Note that `contentEditable` doesn't have this problem: its DOM
431
- // property is also enumerated string values.
432
- if (key === 'spellcheck' || key === 'draggable' || key === 'translate') {
433
- return false;
434
- }
435
- // #1787, #2840 form property on form elements is readonly and must be set as
436
- // attribute.
437
- if (key === 'form') {
438
- return false;
439
- }
440
- // #1526 <input list> must be set as attribute
441
- if (key === 'list' && el.tagName === 'INPUT') {
442
- return false;
443
- }
444
- // #2766 <textarea type> must be set as attribute
445
- if (key === 'type' && el.tagName === 'TEXTAREA') {
446
- return false;
447
- }
448
- // native onclick with string value, must be set as attribute
449
- if (nativeOnRE.test(key) && shared.isString(value)) {
450
- return false;
451
- }
452
- return key in el;
362
+ const nativeOnRE = /^on[a-z]/;
363
+ const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
364
+ if (key === 'class') {
365
+ patchClass(el, nextValue, isSVG);
366
+ }
367
+ else if (key === 'style') {
368
+ patchStyle(el, prevValue, nextValue);
369
+ }
370
+ else if (shared.isOn(key)) {
371
+ // ignore v-model listeners
372
+ if (!shared.isModelListener(key)) {
373
+ patchEvent(el, key, prevValue, nextValue, parentComponent);
374
+ }
375
+ }
376
+ else if (key[0] === '.'
377
+ ? ((key = key.slice(1)), true)
378
+ : key[0] === '^'
379
+ ? ((key = key.slice(1)), false)
380
+ : shouldSetAsProp(el, key, nextValue, isSVG)) {
381
+ patchDOMProp(el, key, nextValue, prevChildren, parentComponent, parentSuspense, unmountChildren);
382
+ }
383
+ else {
384
+ // special case for <input v-model type="checkbox"> with
385
+ // :true-value & :false-value
386
+ // store value as dom properties since non-string values will be
387
+ // stringified.
388
+ if (key === 'true-value') {
389
+ el._trueValue = nextValue;
390
+ }
391
+ else if (key === 'false-value') {
392
+ el._falseValue = nextValue;
393
+ }
394
+ patchAttr(el, key, nextValue, isSVG);
395
+ }
396
+ };
397
+ function shouldSetAsProp(el, key, value, isSVG) {
398
+ if (isSVG) {
399
+ // most keys must be set as attribute on svg elements to work
400
+ // ...except innerHTML & textContent
401
+ if (key === 'innerHTML' || key === 'textContent') {
402
+ return true;
403
+ }
404
+ // or native onclick with function values
405
+ if (key in el && nativeOnRE.test(key) && shared.isFunction(value)) {
406
+ return true;
407
+ }
408
+ return false;
409
+ }
410
+ // these are enumerated attrs, however their corresponding DOM properties
411
+ // are actually booleans - this leads to setting it with a string "false"
412
+ // value leading it to be coerced to `true`, so we need to always treat
413
+ // them as attributes.
414
+ // Note that `contentEditable` doesn't have this problem: its DOM
415
+ // property is also enumerated string values.
416
+ if (key === 'spellcheck' || key === 'draggable' || key === 'translate') {
417
+ return false;
418
+ }
419
+ // #1787, #2840 form property on form elements is readonly and must be set as
420
+ // attribute.
421
+ if (key === 'form') {
422
+ return false;
423
+ }
424
+ // #1526 <input list> must be set as attribute
425
+ if (key === 'list' && el.tagName === 'INPUT') {
426
+ return false;
427
+ }
428
+ // #2766 <textarea type> must be set as attribute
429
+ if (key === 'type' && el.tagName === 'TEXTAREA') {
430
+ return false;
431
+ }
432
+ // native onclick with string value, must be set as attribute
433
+ if (nativeOnRE.test(key) && shared.isString(value)) {
434
+ return false;
435
+ }
436
+ return key in el;
453
437
  }
454
438
 
455
- function defineCustomElement(options, hydrate) {
456
- const Comp = runtimeCore.defineComponent(options);
457
- class VueCustomElement extends VueElement {
458
- constructor(initialProps) {
459
- super(Comp, initialProps, hydrate);
460
- }
461
- }
462
- VueCustomElement.def = Comp;
463
- return VueCustomElement;
464
- }
465
- const defineSSRCustomElement = ((options) => {
466
- // @ts-ignore
467
- return defineCustomElement(options, hydrate);
468
- });
469
- const BaseClass = (typeof HTMLElement !== 'undefined' ? HTMLElement : class {
470
- });
471
- class VueElement extends BaseClass {
472
- constructor(_def, _props = {}, hydrate) {
473
- super();
474
- this._def = _def;
475
- this._props = _props;
476
- /**
477
- * @internal
478
- */
479
- this._instance = null;
480
- this._connected = false;
481
- this._resolved = false;
482
- this._numberProps = null;
483
- if (this.shadowRoot && hydrate) {
484
- hydrate(this._createVNode(), this.shadowRoot);
485
- }
486
- else {
487
- if (this.shadowRoot) {
488
- runtimeCore.warn(`Custom element has pre-rendered declarative shadow root but is not ` +
489
- `defined as hydratable. Use \`defineSSRCustomElement\`.`);
490
- }
491
- this.attachShadow({ mode: 'open' });
492
- }
493
- }
494
- connectedCallback() {
495
- this._connected = true;
496
- if (!this._instance) {
497
- this._resolveDef();
498
- }
499
- }
500
- disconnectedCallback() {
501
- this._connected = false;
502
- runtimeCore.nextTick(() => {
503
- if (!this._connected) {
504
- render(null, this.shadowRoot);
505
- this._instance = null;
506
- }
507
- });
508
- }
509
- /**
510
- * resolve inner component definition (handle possible async component)
511
- */
512
- _resolveDef() {
513
- if (this._resolved) {
514
- return;
515
- }
516
- this._resolved = true;
517
- // set initial attrs
518
- for (let i = 0; i < this.attributes.length; i++) {
519
- this._setAttr(this.attributes[i].name);
520
- }
521
- // watch future attr changes
522
- new MutationObserver(mutations => {
523
- for (const m of mutations) {
524
- this._setAttr(m.attributeName);
525
- }
526
- }).observe(this, { attributes: true });
527
- const resolve = (def) => {
528
- const { props, styles } = def;
529
- const hasOptions = !shared.isArray(props);
530
- const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
531
- // cast Number-type props set before resolve
532
- let numberProps;
533
- if (hasOptions) {
534
- for (const key in this._props) {
535
- const opt = props[key];
536
- if (opt === Number || (opt && opt.type === Number)) {
537
- this._props[key] = shared.toNumber(this._props[key]);
538
- (numberProps || (numberProps = Object.create(null)))[key] = true;
539
- }
540
- }
541
- }
542
- this._numberProps = numberProps;
543
- // check if there are props set pre-upgrade or connect
544
- for (const key of Object.keys(this)) {
545
- if (key[0] !== '_') {
546
- this._setProp(key, this[key], true, false);
547
- }
548
- }
549
- // defining getter/setters on prototype
550
- for (const key of rawKeys.map(shared.camelize)) {
551
- Object.defineProperty(this, key, {
552
- get() {
553
- return this._getProp(key);
554
- },
555
- set(val) {
556
- this._setProp(key, val);
557
- }
558
- });
559
- }
560
- // apply CSS
561
- this._applyStyles(styles);
562
- // initial render
563
- this._update();
564
- };
565
- const asyncDef = this._def.__asyncLoader;
566
- if (asyncDef) {
567
- asyncDef().then(resolve);
568
- }
569
- else {
570
- resolve(this._def);
571
- }
572
- }
573
- _setAttr(key) {
574
- let value = this.getAttribute(key);
575
- if (this._numberProps && this._numberProps[key]) {
576
- value = shared.toNumber(value);
577
- }
578
- this._setProp(shared.camelize(key), value, false);
579
- }
580
- /**
581
- * @internal
582
- */
583
- _getProp(key) {
584
- return this._props[key];
585
- }
586
- /**
587
- * @internal
588
- */
589
- _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
590
- if (val !== this._props[key]) {
591
- this._props[key] = val;
592
- if (shouldUpdate && this._instance) {
593
- this._update();
594
- }
595
- // reflect
596
- if (shouldReflect) {
597
- if (val === true) {
598
- this.setAttribute(shared.hyphenate(key), '');
599
- }
600
- else if (typeof val === 'string' || typeof val === 'number') {
601
- this.setAttribute(shared.hyphenate(key), val + '');
602
- }
603
- else if (!val) {
604
- this.removeAttribute(shared.hyphenate(key));
605
- }
606
- }
607
- }
608
- }
609
- _update() {
610
- render(this._createVNode(), this.shadowRoot);
611
- }
612
- _createVNode() {
613
- const vnode = runtimeCore.createVNode(this._def, shared.extend({}, this._props));
614
- if (!this._instance) {
615
- vnode.ce = instance => {
616
- this._instance = instance;
617
- instance.isCE = true;
618
- // HMR
619
- {
620
- instance.ceReload = newStyles => {
621
- // always reset styles
622
- if (this._styles) {
623
- this._styles.forEach(s => this.shadowRoot.removeChild(s));
624
- this._styles.length = 0;
625
- }
626
- this._applyStyles(newStyles);
627
- // if this is an async component, ceReload is called from the inner
628
- // component so no need to reload the async wrapper
629
- if (!this._def.__asyncLoader) {
630
- // reload
631
- this._instance = null;
632
- this._update();
633
- }
634
- };
635
- }
636
- // intercept emit
637
- instance.emit = (event, ...args) => {
638
- this.dispatchEvent(new CustomEvent(event, {
639
- detail: args
640
- }));
641
- };
642
- // locate nearest Vue custom element parent for provide/inject
643
- let parent = this;
644
- while ((parent =
645
- parent && (parent.parentNode || parent.host))) {
646
- if (parent instanceof VueElement) {
647
- instance.parent = parent._instance;
648
- break;
649
- }
650
- }
651
- };
652
- }
653
- return vnode;
654
- }
655
- _applyStyles(styles) {
656
- if (styles) {
657
- styles.forEach(css => {
658
- const s = document.createElement('style');
659
- s.textContent = css;
660
- this.shadowRoot.appendChild(s);
661
- // record for HMR
662
- {
663
- (this._styles || (this._styles = [])).push(s);
664
- }
665
- });
666
- }
667
- }
439
+ function defineCustomElement(options, hydrate) {
440
+ const Comp = runtimeCore.defineComponent(options);
441
+ class VueCustomElement extends VueElement {
442
+ constructor(initialProps) {
443
+ super(Comp, initialProps, hydrate);
444
+ }
445
+ }
446
+ VueCustomElement.def = Comp;
447
+ return VueCustomElement;
448
+ }
449
+ const defineSSRCustomElement = ((options) => {
450
+ // @ts-ignore
451
+ return defineCustomElement(options, hydrate);
452
+ });
453
+ const BaseClass = (typeof HTMLElement !== 'undefined' ? HTMLElement : class {
454
+ });
455
+ class VueElement extends BaseClass {
456
+ constructor(_def, _props = {}, hydrate) {
457
+ super();
458
+ this._def = _def;
459
+ this._props = _props;
460
+ /**
461
+ * @internal
462
+ */
463
+ this._instance = null;
464
+ this._connected = false;
465
+ this._resolved = false;
466
+ this._numberProps = null;
467
+ if (this.shadowRoot && hydrate) {
468
+ hydrate(this._createVNode(), this.shadowRoot);
469
+ }
470
+ else {
471
+ if (this.shadowRoot) {
472
+ runtimeCore.warn(`Custom element has pre-rendered declarative shadow root but is not ` +
473
+ `defined as hydratable. Use \`defineSSRCustomElement\`.`);
474
+ }
475
+ this.attachShadow({ mode: 'open' });
476
+ }
477
+ }
478
+ connectedCallback() {
479
+ this._connected = true;
480
+ if (!this._instance) {
481
+ this._resolveDef();
482
+ }
483
+ }
484
+ disconnectedCallback() {
485
+ this._connected = false;
486
+ runtimeCore.nextTick(() => {
487
+ if (!this._connected) {
488
+ render(null, this.shadowRoot);
489
+ this._instance = null;
490
+ }
491
+ });
492
+ }
493
+ /**
494
+ * resolve inner component definition (handle possible async component)
495
+ */
496
+ _resolveDef() {
497
+ if (this._resolved) {
498
+ return;
499
+ }
500
+ this._resolved = true;
501
+ // set initial attrs
502
+ for (let i = 0; i < this.attributes.length; i++) {
503
+ this._setAttr(this.attributes[i].name);
504
+ }
505
+ // watch future attr changes
506
+ new MutationObserver(mutations => {
507
+ for (const m of mutations) {
508
+ this._setAttr(m.attributeName);
509
+ }
510
+ }).observe(this, { attributes: true });
511
+ const resolve = (def) => {
512
+ const { props, styles } = def;
513
+ const hasOptions = !shared.isArray(props);
514
+ const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
515
+ // cast Number-type props set before resolve
516
+ let numberProps;
517
+ if (hasOptions) {
518
+ for (const key in this._props) {
519
+ const opt = props[key];
520
+ if (opt === Number || (opt && opt.type === Number)) {
521
+ this._props[key] = shared.toNumber(this._props[key]);
522
+ (numberProps || (numberProps = Object.create(null)))[key] = true;
523
+ }
524
+ }
525
+ }
526
+ this._numberProps = numberProps;
527
+ // check if there are props set pre-upgrade or connect
528
+ for (const key of Object.keys(this)) {
529
+ if (key[0] !== '_') {
530
+ this._setProp(key, this[key], true, false);
531
+ }
532
+ }
533
+ // defining getter/setters on prototype
534
+ for (const key of rawKeys.map(shared.camelize)) {
535
+ Object.defineProperty(this, key, {
536
+ get() {
537
+ return this._getProp(key);
538
+ },
539
+ set(val) {
540
+ this._setProp(key, val);
541
+ }
542
+ });
543
+ }
544
+ // apply CSS
545
+ this._applyStyles(styles);
546
+ // initial render
547
+ this._update();
548
+ };
549
+ const asyncDef = this._def.__asyncLoader;
550
+ if (asyncDef) {
551
+ asyncDef().then(resolve);
552
+ }
553
+ else {
554
+ resolve(this._def);
555
+ }
556
+ }
557
+ _setAttr(key) {
558
+ let value = this.getAttribute(key);
559
+ if (this._numberProps && this._numberProps[key]) {
560
+ value = shared.toNumber(value);
561
+ }
562
+ this._setProp(shared.camelize(key), value, false);
563
+ }
564
+ /**
565
+ * @internal
566
+ */
567
+ _getProp(key) {
568
+ return this._props[key];
569
+ }
570
+ /**
571
+ * @internal
572
+ */
573
+ _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
574
+ if (val !== this._props[key]) {
575
+ this._props[key] = val;
576
+ if (shouldUpdate && this._instance) {
577
+ this._update();
578
+ }
579
+ // reflect
580
+ if (shouldReflect) {
581
+ if (val === true) {
582
+ this.setAttribute(shared.hyphenate(key), '');
583
+ }
584
+ else if (typeof val === 'string' || typeof val === 'number') {
585
+ this.setAttribute(shared.hyphenate(key), val + '');
586
+ }
587
+ else if (!val) {
588
+ this.removeAttribute(shared.hyphenate(key));
589
+ }
590
+ }
591
+ }
592
+ }
593
+ _update() {
594
+ render(this._createVNode(), this.shadowRoot);
595
+ }
596
+ _createVNode() {
597
+ const vnode = runtimeCore.createVNode(this._def, shared.extend({}, this._props));
598
+ if (!this._instance) {
599
+ vnode.ce = instance => {
600
+ this._instance = instance;
601
+ instance.isCE = true;
602
+ // HMR
603
+ {
604
+ instance.ceReload = newStyles => {
605
+ // always reset styles
606
+ if (this._styles) {
607
+ this._styles.forEach(s => this.shadowRoot.removeChild(s));
608
+ this._styles.length = 0;
609
+ }
610
+ this._applyStyles(newStyles);
611
+ // if this is an async component, ceReload is called from the inner
612
+ // component so no need to reload the async wrapper
613
+ if (!this._def.__asyncLoader) {
614
+ // reload
615
+ this._instance = null;
616
+ this._update();
617
+ }
618
+ };
619
+ }
620
+ // intercept emit
621
+ instance.emit = (event, ...args) => {
622
+ this.dispatchEvent(new CustomEvent(event, {
623
+ detail: args
624
+ }));
625
+ };
626
+ // locate nearest Vue custom element parent for provide/inject
627
+ let parent = this;
628
+ while ((parent =
629
+ parent && (parent.parentNode || parent.host))) {
630
+ if (parent instanceof VueElement) {
631
+ instance.parent = parent._instance;
632
+ break;
633
+ }
634
+ }
635
+ };
636
+ }
637
+ return vnode;
638
+ }
639
+ _applyStyles(styles) {
640
+ if (styles) {
641
+ styles.forEach(css => {
642
+ const s = document.createElement('style');
643
+ s.textContent = css;
644
+ this.shadowRoot.appendChild(s);
645
+ // record for HMR
646
+ {
647
+ (this._styles || (this._styles = [])).push(s);
648
+ }
649
+ });
650
+ }
651
+ }
668
652
  }
669
653
 
670
- function useCssModule(name = '$style') {
671
- /* istanbul ignore else */
672
- {
673
- const instance = runtimeCore.getCurrentInstance();
674
- if (!instance) {
675
- runtimeCore.warn(`useCssModule must be called inside setup()`);
676
- return shared.EMPTY_OBJ;
677
- }
678
- const modules = instance.type.__cssModules;
679
- if (!modules) {
680
- runtimeCore.warn(`Current instance does not have CSS modules injected.`);
681
- return shared.EMPTY_OBJ;
682
- }
683
- const mod = modules[name];
684
- if (!mod) {
685
- runtimeCore.warn(`Current instance does not have CSS module named "${name}".`);
686
- return shared.EMPTY_OBJ;
687
- }
688
- return mod;
689
- }
654
+ function useCssModule(name = '$style') {
655
+ /* istanbul ignore else */
656
+ {
657
+ const instance = runtimeCore.getCurrentInstance();
658
+ if (!instance) {
659
+ runtimeCore.warn(`useCssModule must be called inside setup()`);
660
+ return shared.EMPTY_OBJ;
661
+ }
662
+ const modules = instance.type.__cssModules;
663
+ if (!modules) {
664
+ runtimeCore.warn(`Current instance does not have CSS modules injected.`);
665
+ return shared.EMPTY_OBJ;
666
+ }
667
+ const mod = modules[name];
668
+ if (!mod) {
669
+ runtimeCore.warn(`Current instance does not have CSS module named "${name}".`);
670
+ return shared.EMPTY_OBJ;
671
+ }
672
+ return mod;
673
+ }
690
674
  }
691
675
 
692
- /**
693
- * Runtime helper for SFC's CSS variable injection feature.
694
- * @private
695
- */
696
- function useCssVars(getter) {
697
- return;
676
+ /**
677
+ * Runtime helper for SFC's CSS variable injection feature.
678
+ * @private
679
+ */
680
+ function useCssVars(getter) {
681
+ return;
698
682
  }
699
683
 
700
- const TRANSITION = 'transition';
701
- const ANIMATION = 'animation';
702
- // DOM Transition is a higher-order-component based on the platform-agnostic
703
- // base Transition component, with DOM-specific logic.
704
- const Transition = (props, { slots }) => runtimeCore.h(runtimeCore.BaseTransition, resolveTransitionProps(props), slots);
705
- Transition.displayName = 'Transition';
706
- const DOMTransitionPropsValidators = {
707
- name: String,
708
- type: String,
709
- css: {
710
- type: Boolean,
711
- default: true
712
- },
713
- duration: [String, Number, Object],
714
- enterFromClass: String,
715
- enterActiveClass: String,
716
- enterToClass: String,
717
- appearFromClass: String,
718
- appearActiveClass: String,
719
- appearToClass: String,
720
- leaveFromClass: String,
721
- leaveActiveClass: String,
722
- leaveToClass: String
723
- };
724
- const TransitionPropsValidators = (Transition.props =
725
- /*#__PURE__*/ shared.extend({}, runtimeCore.BaseTransition.props, DOMTransitionPropsValidators));
726
- /**
727
- * #3227 Incoming hooks may be merged into arrays when wrapping Transition
728
- * with custom HOCs.
729
- */
730
- const callHook = (hook, args = []) => {
731
- if (shared.isArray(hook)) {
732
- hook.forEach(h => h(...args));
733
- }
734
- else if (hook) {
735
- hook(...args);
736
- }
737
- };
738
- /**
739
- * Check if a hook expects a callback (2nd arg), which means the user
740
- * intends to explicitly control the end of the transition.
741
- */
742
- const hasExplicitCallback = (hook) => {
743
- return hook
744
- ? shared.isArray(hook)
745
- ? hook.some(h => h.length > 1)
746
- : hook.length > 1
747
- : false;
748
- };
749
- function resolveTransitionProps(rawProps) {
750
- const baseProps = {};
751
- for (const key in rawProps) {
752
- if (!(key in DOMTransitionPropsValidators)) {
753
- baseProps[key] = rawProps[key];
754
- }
755
- }
756
- if (rawProps.css === false) {
757
- return baseProps;
758
- }
759
- const { name = 'v', type, duration, enterFromClass = `${name}-enter-from`, enterActiveClass = `${name}-enter-active`, enterToClass = `${name}-enter-to`, appearFromClass = enterFromClass, appearActiveClass = enterActiveClass, appearToClass = enterToClass, leaveFromClass = `${name}-leave-from`, leaveActiveClass = `${name}-leave-active`, leaveToClass = `${name}-leave-to` } = rawProps;
760
- const durations = normalizeDuration(duration);
761
- const enterDuration = durations && durations[0];
762
- const leaveDuration = durations && durations[1];
763
- const { onBeforeEnter, onEnter, onEnterCancelled, onLeave, onLeaveCancelled, onBeforeAppear = onBeforeEnter, onAppear = onEnter, onAppearCancelled = onEnterCancelled } = baseProps;
764
- const finishEnter = (el, isAppear, done) => {
765
- removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
766
- removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
767
- done && done();
768
- };
769
- const finishLeave = (el, done) => {
770
- el._isLeaving = false;
771
- removeTransitionClass(el, leaveFromClass);
772
- removeTransitionClass(el, leaveToClass);
773
- removeTransitionClass(el, leaveActiveClass);
774
- done && done();
775
- };
776
- const makeEnterHook = (isAppear) => {
777
- return (el, done) => {
778
- const hook = isAppear ? onAppear : onEnter;
779
- const resolve = () => finishEnter(el, isAppear, done);
780
- callHook(hook, [el, resolve]);
781
- nextFrame(() => {
782
- removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
783
- addTransitionClass(el, isAppear ? appearToClass : enterToClass);
784
- if (!hasExplicitCallback(hook)) {
785
- whenTransitionEnds(el, type, enterDuration, resolve);
786
- }
787
- });
788
- };
789
- };
790
- return shared.extend(baseProps, {
791
- onBeforeEnter(el) {
792
- callHook(onBeforeEnter, [el]);
793
- addTransitionClass(el, enterFromClass);
794
- addTransitionClass(el, enterActiveClass);
795
- },
796
- onBeforeAppear(el) {
797
- callHook(onBeforeAppear, [el]);
798
- addTransitionClass(el, appearFromClass);
799
- addTransitionClass(el, appearActiveClass);
800
- },
801
- onEnter: makeEnterHook(false),
802
- onAppear: makeEnterHook(true),
803
- onLeave(el, done) {
804
- el._isLeaving = true;
805
- const resolve = () => finishLeave(el, done);
806
- addTransitionClass(el, leaveFromClass);
807
- // force reflow so *-leave-from classes immediately take effect (#2593)
808
- forceReflow();
809
- addTransitionClass(el, leaveActiveClass);
810
- nextFrame(() => {
811
- if (!el._isLeaving) {
812
- // cancelled
813
- return;
814
- }
815
- removeTransitionClass(el, leaveFromClass);
816
- addTransitionClass(el, leaveToClass);
817
- if (!hasExplicitCallback(onLeave)) {
818
- whenTransitionEnds(el, type, leaveDuration, resolve);
819
- }
820
- });
821
- callHook(onLeave, [el, resolve]);
822
- },
823
- onEnterCancelled(el) {
824
- finishEnter(el, false);
825
- callHook(onEnterCancelled, [el]);
826
- },
827
- onAppearCancelled(el) {
828
- finishEnter(el, true);
829
- callHook(onAppearCancelled, [el]);
830
- },
831
- onLeaveCancelled(el) {
832
- finishLeave(el);
833
- callHook(onLeaveCancelled, [el]);
834
- }
835
- });
836
- }
837
- function normalizeDuration(duration) {
838
- if (duration == null) {
839
- return null;
840
- }
841
- else if (shared.isObject(duration)) {
842
- return [NumberOf(duration.enter), NumberOf(duration.leave)];
843
- }
844
- else {
845
- const n = NumberOf(duration);
846
- return [n, n];
847
- }
848
- }
849
- function NumberOf(val) {
850
- const res = shared.toNumber(val);
851
- validateDuration(res);
852
- return res;
853
- }
854
- function validateDuration(val) {
855
- if (typeof val !== 'number') {
856
- runtimeCore.warn(`<transition> explicit duration is not a valid number - ` +
857
- `got ${JSON.stringify(val)}.`);
858
- }
859
- else if (isNaN(val)) {
860
- runtimeCore.warn(`<transition> explicit duration is NaN - ` +
861
- 'the duration expression might be incorrect.');
862
- }
863
- }
864
- function addTransitionClass(el, cls) {
865
- cls.split(/\s+/).forEach(c => c && el.classList.add(c));
866
- (el._vtc ||
867
- (el._vtc = new Set())).add(cls);
868
- }
869
- function removeTransitionClass(el, cls) {
870
- cls.split(/\s+/).forEach(c => c && el.classList.remove(c));
871
- const { _vtc } = el;
872
- if (_vtc) {
873
- _vtc.delete(cls);
874
- if (!_vtc.size) {
875
- el._vtc = undefined;
876
- }
877
- }
878
- }
879
- function nextFrame(cb) {
880
- requestAnimationFrame(() => {
881
- requestAnimationFrame(cb);
882
- });
883
- }
884
- let endId = 0;
885
- function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
886
- const id = (el._endId = ++endId);
887
- const resolveIfNotStale = () => {
888
- if (id === el._endId) {
889
- resolve();
890
- }
891
- };
892
- if (explicitTimeout) {
893
- return setTimeout(resolveIfNotStale, explicitTimeout);
894
- }
895
- const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
896
- if (!type) {
897
- return resolve();
898
- }
899
- const endEvent = type + 'end';
900
- let ended = 0;
901
- const end = () => {
902
- el.removeEventListener(endEvent, onEnd);
903
- resolveIfNotStale();
904
- };
905
- const onEnd = (e) => {
906
- if (e.target === el && ++ended >= propCount) {
907
- end();
908
- }
909
- };
910
- setTimeout(() => {
911
- if (ended < propCount) {
912
- end();
913
- }
914
- }, timeout + 1);
915
- el.addEventListener(endEvent, onEnd);
916
- }
917
- function getTransitionInfo(el, expectedType) {
918
- const styles = window.getComputedStyle(el);
919
- // JSDOM may return undefined for transition properties
920
- const getStyleProperties = (key) => (styles[key] || '').split(', ');
921
- const transitionDelays = getStyleProperties(TRANSITION + 'Delay');
922
- const transitionDurations = getStyleProperties(TRANSITION + 'Duration');
923
- const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
924
- const animationDelays = getStyleProperties(ANIMATION + 'Delay');
925
- const animationDurations = getStyleProperties(ANIMATION + 'Duration');
926
- const animationTimeout = getTimeout(animationDelays, animationDurations);
927
- let type = null;
928
- let timeout = 0;
929
- let propCount = 0;
930
- /* istanbul ignore if */
931
- if (expectedType === TRANSITION) {
932
- if (transitionTimeout > 0) {
933
- type = TRANSITION;
934
- timeout = transitionTimeout;
935
- propCount = transitionDurations.length;
936
- }
937
- }
938
- else if (expectedType === ANIMATION) {
939
- if (animationTimeout > 0) {
940
- type = ANIMATION;
941
- timeout = animationTimeout;
942
- propCount = animationDurations.length;
943
- }
944
- }
945
- else {
946
- timeout = Math.max(transitionTimeout, animationTimeout);
947
- type =
948
- timeout > 0
949
- ? transitionTimeout > animationTimeout
950
- ? TRANSITION
951
- : ANIMATION
952
- : null;
953
- propCount = type
954
- ? type === TRANSITION
955
- ? transitionDurations.length
956
- : animationDurations.length
957
- : 0;
958
- }
959
- const hasTransform = type === TRANSITION &&
960
- /\b(transform|all)(,|$)/.test(styles[TRANSITION + 'Property']);
961
- return {
962
- type,
963
- timeout,
964
- propCount,
965
- hasTransform
966
- };
967
- }
968
- function getTimeout(delays, durations) {
969
- while (delays.length < durations.length) {
970
- delays = delays.concat(delays);
971
- }
972
- return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
973
- }
974
- // Old versions of Chromium (below 61.0.3163.100) formats floating pointer
975
- // numbers in a locale-dependent way, using a comma instead of a dot.
976
- // If comma is not replaced with a dot, the input will be rounded down
977
- // (i.e. acting as a floor function) causing unexpected behaviors
978
- function toMs(s) {
979
- return Number(s.slice(0, -1).replace(',', '.')) * 1000;
980
- }
981
- // synchronously force layout to put elements into a certain state
982
- function forceReflow() {
983
- return document.body.offsetHeight;
684
+ const TRANSITION = 'transition';
685
+ const ANIMATION = 'animation';
686
+ // DOM Transition is a higher-order-component based on the platform-agnostic
687
+ // base Transition component, with DOM-specific logic.
688
+ const Transition = (props, { slots }) => runtimeCore.h(runtimeCore.BaseTransition, resolveTransitionProps(props), slots);
689
+ Transition.displayName = 'Transition';
690
+ const DOMTransitionPropsValidators = {
691
+ name: String,
692
+ type: String,
693
+ css: {
694
+ type: Boolean,
695
+ default: true
696
+ },
697
+ duration: [String, Number, Object],
698
+ enterFromClass: String,
699
+ enterActiveClass: String,
700
+ enterToClass: String,
701
+ appearFromClass: String,
702
+ appearActiveClass: String,
703
+ appearToClass: String,
704
+ leaveFromClass: String,
705
+ leaveActiveClass: String,
706
+ leaveToClass: String
707
+ };
708
+ const TransitionPropsValidators = (Transition.props =
709
+ /*#__PURE__*/ shared.extend({}, runtimeCore.BaseTransition.props, DOMTransitionPropsValidators));
710
+ /**
711
+ * #3227 Incoming hooks may be merged into arrays when wrapping Transition
712
+ * with custom HOCs.
713
+ */
714
+ const callHook = (hook, args = []) => {
715
+ if (shared.isArray(hook)) {
716
+ hook.forEach(h => h(...args));
717
+ }
718
+ else if (hook) {
719
+ hook(...args);
720
+ }
721
+ };
722
+ /**
723
+ * Check if a hook expects a callback (2nd arg), which means the user
724
+ * intends to explicitly control the end of the transition.
725
+ */
726
+ const hasExplicitCallback = (hook) => {
727
+ return hook
728
+ ? shared.isArray(hook)
729
+ ? hook.some(h => h.length > 1)
730
+ : hook.length > 1
731
+ : false;
732
+ };
733
+ function resolveTransitionProps(rawProps) {
734
+ const baseProps = {};
735
+ for (const key in rawProps) {
736
+ if (!(key in DOMTransitionPropsValidators)) {
737
+ baseProps[key] = rawProps[key];
738
+ }
739
+ }
740
+ if (rawProps.css === false) {
741
+ return baseProps;
742
+ }
743
+ const { name = 'v', type, duration, enterFromClass = `${name}-enter-from`, enterActiveClass = `${name}-enter-active`, enterToClass = `${name}-enter-to`, appearFromClass = enterFromClass, appearActiveClass = enterActiveClass, appearToClass = enterToClass, leaveFromClass = `${name}-leave-from`, leaveActiveClass = `${name}-leave-active`, leaveToClass = `${name}-leave-to` } = rawProps;
744
+ const durations = normalizeDuration(duration);
745
+ const enterDuration = durations && durations[0];
746
+ const leaveDuration = durations && durations[1];
747
+ const { onBeforeEnter, onEnter, onEnterCancelled, onLeave, onLeaveCancelled, onBeforeAppear = onBeforeEnter, onAppear = onEnter, onAppearCancelled = onEnterCancelled } = baseProps;
748
+ const finishEnter = (el, isAppear, done) => {
749
+ removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
750
+ removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
751
+ done && done();
752
+ };
753
+ const finishLeave = (el, done) => {
754
+ el._isLeaving = false;
755
+ removeTransitionClass(el, leaveFromClass);
756
+ removeTransitionClass(el, leaveToClass);
757
+ removeTransitionClass(el, leaveActiveClass);
758
+ done && done();
759
+ };
760
+ const makeEnterHook = (isAppear) => {
761
+ return (el, done) => {
762
+ const hook = isAppear ? onAppear : onEnter;
763
+ const resolve = () => finishEnter(el, isAppear, done);
764
+ callHook(hook, [el, resolve]);
765
+ nextFrame(() => {
766
+ removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
767
+ addTransitionClass(el, isAppear ? appearToClass : enterToClass);
768
+ if (!hasExplicitCallback(hook)) {
769
+ whenTransitionEnds(el, type, enterDuration, resolve);
770
+ }
771
+ });
772
+ };
773
+ };
774
+ return shared.extend(baseProps, {
775
+ onBeforeEnter(el) {
776
+ callHook(onBeforeEnter, [el]);
777
+ addTransitionClass(el, enterFromClass);
778
+ addTransitionClass(el, enterActiveClass);
779
+ },
780
+ onBeforeAppear(el) {
781
+ callHook(onBeforeAppear, [el]);
782
+ addTransitionClass(el, appearFromClass);
783
+ addTransitionClass(el, appearActiveClass);
784
+ },
785
+ onEnter: makeEnterHook(false),
786
+ onAppear: makeEnterHook(true),
787
+ onLeave(el, done) {
788
+ el._isLeaving = true;
789
+ const resolve = () => finishLeave(el, done);
790
+ addTransitionClass(el, leaveFromClass);
791
+ // force reflow so *-leave-from classes immediately take effect (#2593)
792
+ forceReflow();
793
+ addTransitionClass(el, leaveActiveClass);
794
+ nextFrame(() => {
795
+ if (!el._isLeaving) {
796
+ // cancelled
797
+ return;
798
+ }
799
+ removeTransitionClass(el, leaveFromClass);
800
+ addTransitionClass(el, leaveToClass);
801
+ if (!hasExplicitCallback(onLeave)) {
802
+ whenTransitionEnds(el, type, leaveDuration, resolve);
803
+ }
804
+ });
805
+ callHook(onLeave, [el, resolve]);
806
+ },
807
+ onEnterCancelled(el) {
808
+ finishEnter(el, false);
809
+ callHook(onEnterCancelled, [el]);
810
+ },
811
+ onAppearCancelled(el) {
812
+ finishEnter(el, true);
813
+ callHook(onAppearCancelled, [el]);
814
+ },
815
+ onLeaveCancelled(el) {
816
+ finishLeave(el);
817
+ callHook(onLeaveCancelled, [el]);
818
+ }
819
+ });
820
+ }
821
+ function normalizeDuration(duration) {
822
+ if (duration == null) {
823
+ return null;
824
+ }
825
+ else if (shared.isObject(duration)) {
826
+ return [NumberOf(duration.enter), NumberOf(duration.leave)];
827
+ }
828
+ else {
829
+ const n = NumberOf(duration);
830
+ return [n, n];
831
+ }
832
+ }
833
+ function NumberOf(val) {
834
+ const res = shared.toNumber(val);
835
+ validateDuration(res);
836
+ return res;
837
+ }
838
+ function validateDuration(val) {
839
+ if (typeof val !== 'number') {
840
+ runtimeCore.warn(`<transition> explicit duration is not a valid number - ` +
841
+ `got ${JSON.stringify(val)}.`);
842
+ }
843
+ else if (isNaN(val)) {
844
+ runtimeCore.warn(`<transition> explicit duration is NaN - ` +
845
+ 'the duration expression might be incorrect.');
846
+ }
847
+ }
848
+ function addTransitionClass(el, cls) {
849
+ cls.split(/\s+/).forEach(c => c && el.classList.add(c));
850
+ (el._vtc ||
851
+ (el._vtc = new Set())).add(cls);
852
+ }
853
+ function removeTransitionClass(el, cls) {
854
+ cls.split(/\s+/).forEach(c => c && el.classList.remove(c));
855
+ const { _vtc } = el;
856
+ if (_vtc) {
857
+ _vtc.delete(cls);
858
+ if (!_vtc.size) {
859
+ el._vtc = undefined;
860
+ }
861
+ }
862
+ }
863
+ function nextFrame(cb) {
864
+ requestAnimationFrame(() => {
865
+ requestAnimationFrame(cb);
866
+ });
867
+ }
868
+ let endId = 0;
869
+ function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
870
+ const id = (el._endId = ++endId);
871
+ const resolveIfNotStale = () => {
872
+ if (id === el._endId) {
873
+ resolve();
874
+ }
875
+ };
876
+ if (explicitTimeout) {
877
+ return setTimeout(resolveIfNotStale, explicitTimeout);
878
+ }
879
+ const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
880
+ if (!type) {
881
+ return resolve();
882
+ }
883
+ const endEvent = type + 'end';
884
+ let ended = 0;
885
+ const end = () => {
886
+ el.removeEventListener(endEvent, onEnd);
887
+ resolveIfNotStale();
888
+ };
889
+ const onEnd = (e) => {
890
+ if (e.target === el && ++ended >= propCount) {
891
+ end();
892
+ }
893
+ };
894
+ setTimeout(() => {
895
+ if (ended < propCount) {
896
+ end();
897
+ }
898
+ }, timeout + 1);
899
+ el.addEventListener(endEvent, onEnd);
900
+ }
901
+ function getTransitionInfo(el, expectedType) {
902
+ const styles = window.getComputedStyle(el);
903
+ // JSDOM may return undefined for transition properties
904
+ const getStyleProperties = (key) => (styles[key] || '').split(', ');
905
+ const transitionDelays = getStyleProperties(TRANSITION + 'Delay');
906
+ const transitionDurations = getStyleProperties(TRANSITION + 'Duration');
907
+ const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
908
+ const animationDelays = getStyleProperties(ANIMATION + 'Delay');
909
+ const animationDurations = getStyleProperties(ANIMATION + 'Duration');
910
+ const animationTimeout = getTimeout(animationDelays, animationDurations);
911
+ let type = null;
912
+ let timeout = 0;
913
+ let propCount = 0;
914
+ /* istanbul ignore if */
915
+ if (expectedType === TRANSITION) {
916
+ if (transitionTimeout > 0) {
917
+ type = TRANSITION;
918
+ timeout = transitionTimeout;
919
+ propCount = transitionDurations.length;
920
+ }
921
+ }
922
+ else if (expectedType === ANIMATION) {
923
+ if (animationTimeout > 0) {
924
+ type = ANIMATION;
925
+ timeout = animationTimeout;
926
+ propCount = animationDurations.length;
927
+ }
928
+ }
929
+ else {
930
+ timeout = Math.max(transitionTimeout, animationTimeout);
931
+ type =
932
+ timeout > 0
933
+ ? transitionTimeout > animationTimeout
934
+ ? TRANSITION
935
+ : ANIMATION
936
+ : null;
937
+ propCount = type
938
+ ? type === TRANSITION
939
+ ? transitionDurations.length
940
+ : animationDurations.length
941
+ : 0;
942
+ }
943
+ const hasTransform = type === TRANSITION &&
944
+ /\b(transform|all)(,|$)/.test(styles[TRANSITION + 'Property']);
945
+ return {
946
+ type,
947
+ timeout,
948
+ propCount,
949
+ hasTransform
950
+ };
951
+ }
952
+ function getTimeout(delays, durations) {
953
+ while (delays.length < durations.length) {
954
+ delays = delays.concat(delays);
955
+ }
956
+ return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
957
+ }
958
+ // Old versions of Chromium (below 61.0.3163.100) formats floating pointer
959
+ // numbers in a locale-dependent way, using a comma instead of a dot.
960
+ // If comma is not replaced with a dot, the input will be rounded down
961
+ // (i.e. acting as a floor function) causing unexpected behaviors
962
+ function toMs(s) {
963
+ return Number(s.slice(0, -1).replace(',', '.')) * 1000;
964
+ }
965
+ // synchronously force layout to put elements into a certain state
966
+ function forceReflow() {
967
+ return document.body.offsetHeight;
984
968
  }
985
969
 
986
- const positionMap = new WeakMap();
987
- const newPositionMap = new WeakMap();
988
- const TransitionGroupImpl = {
989
- name: 'TransitionGroup',
990
- props: /*#__PURE__*/ shared.extend({}, TransitionPropsValidators, {
991
- tag: String,
992
- moveClass: String
993
- }),
994
- setup(props, { slots }) {
995
- const instance = runtimeCore.getCurrentInstance();
996
- const state = runtimeCore.useTransitionState();
997
- let prevChildren;
998
- let children;
999
- runtimeCore.onUpdated(() => {
1000
- // children is guaranteed to exist after initial render
1001
- if (!prevChildren.length) {
1002
- return;
1003
- }
1004
- const moveClass = props.moveClass || `${props.name || 'v'}-move`;
1005
- if (!hasCSSTransform(prevChildren[0].el, instance.vnode.el, moveClass)) {
1006
- return;
1007
- }
1008
- // we divide the work into three loops to avoid mixing DOM reads and writes
1009
- // in each iteration - which helps prevent layout thrashing.
1010
- prevChildren.forEach(callPendingCbs);
1011
- prevChildren.forEach(recordPosition);
1012
- const movedChildren = prevChildren.filter(applyTranslation);
1013
- // force reflow to put everything in position
1014
- forceReflow();
1015
- movedChildren.forEach(c => {
1016
- const el = c.el;
1017
- const style = el.style;
1018
- addTransitionClass(el, moveClass);
1019
- style.transform = style.webkitTransform = style.transitionDuration = '';
1020
- const cb = (el._moveCb = (e) => {
1021
- if (e && e.target !== el) {
1022
- return;
1023
- }
1024
- if (!e || /transform$/.test(e.propertyName)) {
1025
- el.removeEventListener('transitionend', cb);
1026
- el._moveCb = null;
1027
- removeTransitionClass(el, moveClass);
1028
- }
1029
- });
1030
- el.addEventListener('transitionend', cb);
1031
- });
1032
- });
1033
- return () => {
1034
- const rawProps = runtimeCore.toRaw(props);
1035
- const cssTransitionProps = resolveTransitionProps(rawProps);
1036
- let tag = rawProps.tag || runtimeCore.Fragment;
1037
- prevChildren = children;
1038
- children = slots.default ? runtimeCore.getTransitionRawChildren(slots.default()) : [];
1039
- for (let i = 0; i < children.length; i++) {
1040
- const child = children[i];
1041
- if (child.key != null) {
1042
- runtimeCore.setTransitionHooks(child, runtimeCore.resolveTransitionHooks(child, cssTransitionProps, state, instance));
1043
- }
1044
- else {
1045
- runtimeCore.warn(`<TransitionGroup> children must be keyed.`);
1046
- }
1047
- }
1048
- if (prevChildren) {
1049
- for (let i = 0; i < prevChildren.length; i++) {
1050
- const child = prevChildren[i];
1051
- runtimeCore.setTransitionHooks(child, runtimeCore.resolveTransitionHooks(child, cssTransitionProps, state, instance));
1052
- positionMap.set(child, child.el.getBoundingClientRect());
1053
- }
1054
- }
1055
- return runtimeCore.createVNode(tag, null, children);
1056
- };
1057
- }
1058
- };
1059
- const TransitionGroup = TransitionGroupImpl;
1060
- function callPendingCbs(c) {
1061
- const el = c.el;
1062
- if (el._moveCb) {
1063
- el._moveCb();
1064
- }
1065
- if (el._enterCb) {
1066
- el._enterCb();
1067
- }
1068
- }
1069
- function recordPosition(c) {
1070
- newPositionMap.set(c, c.el.getBoundingClientRect());
1071
- }
1072
- function applyTranslation(c) {
1073
- const oldPos = positionMap.get(c);
1074
- const newPos = newPositionMap.get(c);
1075
- const dx = oldPos.left - newPos.left;
1076
- const dy = oldPos.top - newPos.top;
1077
- if (dx || dy) {
1078
- const s = c.el.style;
1079
- s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
1080
- s.transitionDuration = '0s';
1081
- return c;
1082
- }
1083
- }
1084
- function hasCSSTransform(el, root, moveClass) {
1085
- // Detect whether an element with the move class applied has
1086
- // CSS transitions. Since the element may be inside an entering
1087
- // transition at this very moment, we make a clone of it and remove
1088
- // all other transition classes applied to ensure only the move class
1089
- // is applied.
1090
- const clone = el.cloneNode();
1091
- if (el._vtc) {
1092
- el._vtc.forEach(cls => {
1093
- cls.split(/\s+/).forEach(c => c && clone.classList.remove(c));
1094
- });
1095
- }
1096
- moveClass.split(/\s+/).forEach(c => c && clone.classList.add(c));
1097
- clone.style.display = 'none';
1098
- const container = (root.nodeType === 1 ? root : root.parentNode);
1099
- container.appendChild(clone);
1100
- const { hasTransform } = getTransitionInfo(clone);
1101
- container.removeChild(clone);
1102
- return hasTransform;
970
+ const positionMap = new WeakMap();
971
+ const newPositionMap = new WeakMap();
972
+ const TransitionGroupImpl = {
973
+ name: 'TransitionGroup',
974
+ props: /*#__PURE__*/ shared.extend({}, TransitionPropsValidators, {
975
+ tag: String,
976
+ moveClass: String
977
+ }),
978
+ setup(props, { slots }) {
979
+ const instance = runtimeCore.getCurrentInstance();
980
+ const state = runtimeCore.useTransitionState();
981
+ let prevChildren;
982
+ let children;
983
+ runtimeCore.onUpdated(() => {
984
+ // children is guaranteed to exist after initial render
985
+ if (!prevChildren.length) {
986
+ return;
987
+ }
988
+ const moveClass = props.moveClass || `${props.name || 'v'}-move`;
989
+ if (!hasCSSTransform(prevChildren[0].el, instance.vnode.el, moveClass)) {
990
+ return;
991
+ }
992
+ // we divide the work into three loops to avoid mixing DOM reads and writes
993
+ // in each iteration - which helps prevent layout thrashing.
994
+ prevChildren.forEach(callPendingCbs);
995
+ prevChildren.forEach(recordPosition);
996
+ const movedChildren = prevChildren.filter(applyTranslation);
997
+ // force reflow to put everything in position
998
+ forceReflow();
999
+ movedChildren.forEach(c => {
1000
+ const el = c.el;
1001
+ const style = el.style;
1002
+ addTransitionClass(el, moveClass);
1003
+ style.transform = style.webkitTransform = style.transitionDuration = '';
1004
+ const cb = (el._moveCb = (e) => {
1005
+ if (e && e.target !== el) {
1006
+ return;
1007
+ }
1008
+ if (!e || /transform$/.test(e.propertyName)) {
1009
+ el.removeEventListener('transitionend', cb);
1010
+ el._moveCb = null;
1011
+ removeTransitionClass(el, moveClass);
1012
+ }
1013
+ });
1014
+ el.addEventListener('transitionend', cb);
1015
+ });
1016
+ });
1017
+ return () => {
1018
+ const rawProps = runtimeCore.toRaw(props);
1019
+ const cssTransitionProps = resolveTransitionProps(rawProps);
1020
+ let tag = rawProps.tag || runtimeCore.Fragment;
1021
+ prevChildren = children;
1022
+ children = slots.default ? runtimeCore.getTransitionRawChildren(slots.default()) : [];
1023
+ for (let i = 0; i < children.length; i++) {
1024
+ const child = children[i];
1025
+ if (child.key != null) {
1026
+ runtimeCore.setTransitionHooks(child, runtimeCore.resolveTransitionHooks(child, cssTransitionProps, state, instance));
1027
+ }
1028
+ else {
1029
+ runtimeCore.warn(`<TransitionGroup> children must be keyed.`);
1030
+ }
1031
+ }
1032
+ if (prevChildren) {
1033
+ for (let i = 0; i < prevChildren.length; i++) {
1034
+ const child = prevChildren[i];
1035
+ runtimeCore.setTransitionHooks(child, runtimeCore.resolveTransitionHooks(child, cssTransitionProps, state, instance));
1036
+ positionMap.set(child, child.el.getBoundingClientRect());
1037
+ }
1038
+ }
1039
+ return runtimeCore.createVNode(tag, null, children);
1040
+ };
1041
+ }
1042
+ };
1043
+ const TransitionGroup = TransitionGroupImpl;
1044
+ function callPendingCbs(c) {
1045
+ const el = c.el;
1046
+ if (el._moveCb) {
1047
+ el._moveCb();
1048
+ }
1049
+ if (el._enterCb) {
1050
+ el._enterCb();
1051
+ }
1052
+ }
1053
+ function recordPosition(c) {
1054
+ newPositionMap.set(c, c.el.getBoundingClientRect());
1055
+ }
1056
+ function applyTranslation(c) {
1057
+ const oldPos = positionMap.get(c);
1058
+ const newPos = newPositionMap.get(c);
1059
+ const dx = oldPos.left - newPos.left;
1060
+ const dy = oldPos.top - newPos.top;
1061
+ if (dx || dy) {
1062
+ const s = c.el.style;
1063
+ s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
1064
+ s.transitionDuration = '0s';
1065
+ return c;
1066
+ }
1067
+ }
1068
+ function hasCSSTransform(el, root, moveClass) {
1069
+ // Detect whether an element with the move class applied has
1070
+ // CSS transitions. Since the element may be inside an entering
1071
+ // transition at this very moment, we make a clone of it and remove
1072
+ // all other transition classes applied to ensure only the move class
1073
+ // is applied.
1074
+ const clone = el.cloneNode();
1075
+ if (el._vtc) {
1076
+ el._vtc.forEach(cls => {
1077
+ cls.split(/\s+/).forEach(c => c && clone.classList.remove(c));
1078
+ });
1079
+ }
1080
+ moveClass.split(/\s+/).forEach(c => c && clone.classList.add(c));
1081
+ clone.style.display = 'none';
1082
+ const container = (root.nodeType === 1 ? root : root.parentNode);
1083
+ container.appendChild(clone);
1084
+ const { hasTransform } = getTransitionInfo(clone);
1085
+ container.removeChild(clone);
1086
+ return hasTransform;
1103
1087
  }
1104
1088
 
1105
- const getModelAssigner = (vnode) => {
1106
- const fn = vnode.props['onUpdate:modelValue'] ||
1107
- (false );
1108
- return shared.isArray(fn) ? value => shared.invokeArrayFns(fn, value) : fn;
1109
- };
1110
- function onCompositionStart(e) {
1111
- e.target.composing = true;
1112
- }
1113
- function onCompositionEnd(e) {
1114
- const target = e.target;
1115
- if (target.composing) {
1116
- target.composing = false;
1117
- target.dispatchEvent(new Event('input'));
1118
- }
1119
- }
1120
- // We are exporting the v-model runtime directly as vnode hooks so that it can
1121
- // be tree-shaken in case v-model is never used.
1122
- const vModelText = {
1123
- created(el, { modifiers: { lazy, trim, number } }, vnode) {
1124
- el._assign = getModelAssigner(vnode);
1125
- const castToNumber = number || (vnode.props && vnode.props.type === 'number');
1126
- addEventListener(el, lazy ? 'change' : 'input', e => {
1127
- if (e.target.composing)
1128
- return;
1129
- let domValue = el.value;
1130
- if (trim) {
1131
- domValue = domValue.trim();
1132
- }
1133
- if (castToNumber) {
1134
- domValue = shared.toNumber(domValue);
1135
- }
1136
- el._assign(domValue);
1137
- });
1138
- if (trim) {
1139
- addEventListener(el, 'change', () => {
1140
- el.value = el.value.trim();
1141
- });
1142
- }
1143
- if (!lazy) {
1144
- addEventListener(el, 'compositionstart', onCompositionStart);
1145
- addEventListener(el, 'compositionend', onCompositionEnd);
1146
- // Safari < 10.2 & UIWebView doesn't fire compositionend when
1147
- // switching focus before confirming composition choice
1148
- // this also fixes the issue where some browsers e.g. iOS Chrome
1149
- // fires "change" instead of "input" on autocomplete.
1150
- addEventListener(el, 'change', onCompositionEnd);
1151
- }
1152
- },
1153
- // set value on mounted so it's after min/max for type="range"
1154
- mounted(el, { value }) {
1155
- el.value = value == null ? '' : value;
1156
- },
1157
- beforeUpdate(el, { value, modifiers: { lazy, trim, number } }, vnode) {
1158
- el._assign = getModelAssigner(vnode);
1159
- // avoid clearing unresolved text. #2302
1160
- if (el.composing)
1161
- return;
1162
- if (document.activeElement === el && el.type !== 'range') {
1163
- if (lazy) {
1164
- return;
1165
- }
1166
- if (trim && el.value.trim() === value) {
1167
- return;
1168
- }
1169
- if ((number || el.type === 'number') && shared.toNumber(el.value) === value) {
1170
- return;
1171
- }
1172
- }
1173
- const newValue = value == null ? '' : value;
1174
- if (el.value !== newValue) {
1175
- el.value = newValue;
1176
- }
1177
- }
1178
- };
1179
- const vModelCheckbox = {
1180
- // #4096 array checkboxes need to be deep traversed
1181
- deep: true,
1182
- created(el, _, vnode) {
1183
- el._assign = getModelAssigner(vnode);
1184
- addEventListener(el, 'change', () => {
1185
- const modelValue = el._modelValue;
1186
- const elementValue = getValue(el);
1187
- const checked = el.checked;
1188
- const assign = el._assign;
1189
- if (shared.isArray(modelValue)) {
1190
- const index = shared.looseIndexOf(modelValue, elementValue);
1191
- const found = index !== -1;
1192
- if (checked && !found) {
1193
- assign(modelValue.concat(elementValue));
1194
- }
1195
- else if (!checked && found) {
1196
- const filtered = [...modelValue];
1197
- filtered.splice(index, 1);
1198
- assign(filtered);
1199
- }
1200
- }
1201
- else if (shared.isSet(modelValue)) {
1202
- const cloned = new Set(modelValue);
1203
- if (checked) {
1204
- cloned.add(elementValue);
1205
- }
1206
- else {
1207
- cloned.delete(elementValue);
1208
- }
1209
- assign(cloned);
1210
- }
1211
- else {
1212
- assign(getCheckboxValue(el, checked));
1213
- }
1214
- });
1215
- },
1216
- // set initial checked on mount to wait for true-value/false-value
1217
- mounted: setChecked,
1218
- beforeUpdate(el, binding, vnode) {
1219
- el._assign = getModelAssigner(vnode);
1220
- setChecked(el, binding, vnode);
1221
- }
1222
- };
1223
- function setChecked(el, { value, oldValue }, vnode) {
1224
- el._modelValue = value;
1225
- if (shared.isArray(value)) {
1226
- el.checked = shared.looseIndexOf(value, vnode.props.value) > -1;
1227
- }
1228
- else if (shared.isSet(value)) {
1229
- el.checked = value.has(vnode.props.value);
1230
- }
1231
- else if (value !== oldValue) {
1232
- el.checked = shared.looseEqual(value, getCheckboxValue(el, true));
1233
- }
1234
- }
1235
- const vModelRadio = {
1236
- created(el, { value }, vnode) {
1237
- el.checked = shared.looseEqual(value, vnode.props.value);
1238
- el._assign = getModelAssigner(vnode);
1239
- addEventListener(el, 'change', () => {
1240
- el._assign(getValue(el));
1241
- });
1242
- },
1243
- beforeUpdate(el, { value, oldValue }, vnode) {
1244
- el._assign = getModelAssigner(vnode);
1245
- if (value !== oldValue) {
1246
- el.checked = shared.looseEqual(value, vnode.props.value);
1247
- }
1248
- }
1249
- };
1250
- const vModelSelect = {
1251
- // <select multiple> value need to be deep traversed
1252
- deep: true,
1253
- created(el, { value, modifiers: { number } }, vnode) {
1254
- const isSetModel = shared.isSet(value);
1255
- addEventListener(el, 'change', () => {
1256
- const selectedVal = Array.prototype.filter
1257
- .call(el.options, (o) => o.selected)
1258
- .map((o) => number ? shared.toNumber(getValue(o)) : getValue(o));
1259
- el._assign(el.multiple
1260
- ? isSetModel
1261
- ? new Set(selectedVal)
1262
- : selectedVal
1263
- : selectedVal[0]);
1264
- });
1265
- el._assign = getModelAssigner(vnode);
1266
- },
1267
- // set value in mounted & updated because <select> relies on its children
1268
- // <option>s.
1269
- mounted(el, { value }) {
1270
- setSelected(el, value);
1271
- },
1272
- beforeUpdate(el, _binding, vnode) {
1273
- el._assign = getModelAssigner(vnode);
1274
- },
1275
- updated(el, { value }) {
1276
- setSelected(el, value);
1277
- }
1278
- };
1279
- function setSelected(el, value) {
1280
- const isMultiple = el.multiple;
1281
- if (isMultiple && !shared.isArray(value) && !shared.isSet(value)) {
1282
- runtimeCore.warn(`<select multiple v-model> expects an Array or Set value for its binding, ` +
1283
- `but got ${Object.prototype.toString.call(value).slice(8, -1)}.`);
1284
- return;
1285
- }
1286
- for (let i = 0, l = el.options.length; i < l; i++) {
1287
- const option = el.options[i];
1288
- const optionValue = getValue(option);
1289
- if (isMultiple) {
1290
- if (shared.isArray(value)) {
1291
- option.selected = shared.looseIndexOf(value, optionValue) > -1;
1292
- }
1293
- else {
1294
- option.selected = value.has(optionValue);
1295
- }
1296
- }
1297
- else {
1298
- if (shared.looseEqual(getValue(option), value)) {
1299
- if (el.selectedIndex !== i)
1300
- el.selectedIndex = i;
1301
- return;
1302
- }
1303
- }
1304
- }
1305
- if (!isMultiple && el.selectedIndex !== -1) {
1306
- el.selectedIndex = -1;
1307
- }
1308
- }
1309
- // retrieve raw value set via :value bindings
1310
- function getValue(el) {
1311
- return '_value' in el ? el._value : el.value;
1312
- }
1313
- // retrieve raw value for true-value and false-value set via :true-value or :false-value bindings
1314
- function getCheckboxValue(el, checked) {
1315
- const key = checked ? '_trueValue' : '_falseValue';
1316
- return key in el ? el[key] : checked;
1317
- }
1318
- const vModelDynamic = {
1319
- created(el, binding, vnode) {
1320
- callModelHook(el, binding, vnode, null, 'created');
1321
- },
1322
- mounted(el, binding, vnode) {
1323
- callModelHook(el, binding, vnode, null, 'mounted');
1324
- },
1325
- beforeUpdate(el, binding, vnode, prevVNode) {
1326
- callModelHook(el, binding, vnode, prevVNode, 'beforeUpdate');
1327
- },
1328
- updated(el, binding, vnode, prevVNode) {
1329
- callModelHook(el, binding, vnode, prevVNode, 'updated');
1330
- }
1331
- };
1332
- function resolveDynamicModel(tagName, type) {
1333
- switch (tagName) {
1334
- case 'SELECT':
1335
- return vModelSelect;
1336
- case 'TEXTAREA':
1337
- return vModelText;
1338
- default:
1339
- switch (type) {
1340
- case 'checkbox':
1341
- return vModelCheckbox;
1342
- case 'radio':
1343
- return vModelRadio;
1344
- default:
1345
- return vModelText;
1346
- }
1347
- }
1348
- }
1349
- function callModelHook(el, binding, vnode, prevVNode, hook) {
1350
- const modelToUse = resolveDynamicModel(el.tagName, vnode.props && vnode.props.type);
1351
- const fn = modelToUse[hook];
1352
- fn && fn(el, binding, vnode, prevVNode);
1353
- }
1354
- // SSR vnode transforms, only used when user includes client-oriented render
1355
- // function in SSR
1356
- function initVModelForSSR() {
1357
- vModelText.getSSRProps = ({ value }) => ({ value });
1358
- vModelRadio.getSSRProps = ({ value }, vnode) => {
1359
- if (vnode.props && shared.looseEqual(vnode.props.value, value)) {
1360
- return { checked: true };
1361
- }
1362
- };
1363
- vModelCheckbox.getSSRProps = ({ value }, vnode) => {
1364
- if (shared.isArray(value)) {
1365
- if (vnode.props && shared.looseIndexOf(value, vnode.props.value) > -1) {
1366
- return { checked: true };
1367
- }
1368
- }
1369
- else if (shared.isSet(value)) {
1370
- if (vnode.props && value.has(vnode.props.value)) {
1371
- return { checked: true };
1372
- }
1373
- }
1374
- else if (value) {
1375
- return { checked: true };
1376
- }
1377
- };
1378
- vModelDynamic.getSSRProps = (binding, vnode) => {
1379
- if (typeof vnode.type !== 'string') {
1380
- return;
1381
- }
1382
- const modelToUse = resolveDynamicModel(
1383
- // resolveDynamicModel expects an uppercase tag name, but vnode.type is lowercase
1384
- vnode.type.toUpperCase(), vnode.props && vnode.props.type);
1385
- if (modelToUse.getSSRProps) {
1386
- return modelToUse.getSSRProps(binding, vnode);
1387
- }
1388
- };
1089
+ const getModelAssigner = (vnode) => {
1090
+ const fn = vnode.props['onUpdate:modelValue'] ||
1091
+ (false );
1092
+ return shared.isArray(fn) ? value => shared.invokeArrayFns(fn, value) : fn;
1093
+ };
1094
+ function onCompositionStart(e) {
1095
+ e.target.composing = true;
1096
+ }
1097
+ function onCompositionEnd(e) {
1098
+ const target = e.target;
1099
+ if (target.composing) {
1100
+ target.composing = false;
1101
+ target.dispatchEvent(new Event('input'));
1102
+ }
1103
+ }
1104
+ // We are exporting the v-model runtime directly as vnode hooks so that it can
1105
+ // be tree-shaken in case v-model is never used.
1106
+ const vModelText = {
1107
+ created(el, { modifiers: { lazy, trim, number } }, vnode) {
1108
+ el._assign = getModelAssigner(vnode);
1109
+ const castToNumber = number || (vnode.props && vnode.props.type === 'number');
1110
+ addEventListener(el, lazy ? 'change' : 'input', e => {
1111
+ if (e.target.composing)
1112
+ return;
1113
+ let domValue = el.value;
1114
+ if (trim) {
1115
+ domValue = domValue.trim();
1116
+ }
1117
+ if (castToNumber) {
1118
+ domValue = shared.toNumber(domValue);
1119
+ }
1120
+ el._assign(domValue);
1121
+ });
1122
+ if (trim) {
1123
+ addEventListener(el, 'change', () => {
1124
+ el.value = el.value.trim();
1125
+ });
1126
+ }
1127
+ if (!lazy) {
1128
+ addEventListener(el, 'compositionstart', onCompositionStart);
1129
+ addEventListener(el, 'compositionend', onCompositionEnd);
1130
+ // Safari < 10.2 & UIWebView doesn't fire compositionend when
1131
+ // switching focus before confirming composition choice
1132
+ // this also fixes the issue where some browsers e.g. iOS Chrome
1133
+ // fires "change" instead of "input" on autocomplete.
1134
+ addEventListener(el, 'change', onCompositionEnd);
1135
+ }
1136
+ },
1137
+ // set value on mounted so it's after min/max for type="range"
1138
+ mounted(el, { value }) {
1139
+ el.value = value == null ? '' : value;
1140
+ },
1141
+ beforeUpdate(el, { value, modifiers: { lazy, trim, number } }, vnode) {
1142
+ el._assign = getModelAssigner(vnode);
1143
+ // avoid clearing unresolved text. #2302
1144
+ if (el.composing)
1145
+ return;
1146
+ if (document.activeElement === el && el.type !== 'range') {
1147
+ if (lazy) {
1148
+ return;
1149
+ }
1150
+ if (trim && el.value.trim() === value) {
1151
+ return;
1152
+ }
1153
+ if ((number || el.type === 'number') && shared.toNumber(el.value) === value) {
1154
+ return;
1155
+ }
1156
+ }
1157
+ const newValue = value == null ? '' : value;
1158
+ if (el.value !== newValue) {
1159
+ el.value = newValue;
1160
+ }
1161
+ }
1162
+ };
1163
+ const vModelCheckbox = {
1164
+ // #4096 array checkboxes need to be deep traversed
1165
+ deep: true,
1166
+ created(el, _, vnode) {
1167
+ el._assign = getModelAssigner(vnode);
1168
+ addEventListener(el, 'change', () => {
1169
+ const modelValue = el._modelValue;
1170
+ const elementValue = getValue(el);
1171
+ const checked = el.checked;
1172
+ const assign = el._assign;
1173
+ if (shared.isArray(modelValue)) {
1174
+ const index = shared.looseIndexOf(modelValue, elementValue);
1175
+ const found = index !== -1;
1176
+ if (checked && !found) {
1177
+ assign(modelValue.concat(elementValue));
1178
+ }
1179
+ else if (!checked && found) {
1180
+ const filtered = [...modelValue];
1181
+ filtered.splice(index, 1);
1182
+ assign(filtered);
1183
+ }
1184
+ }
1185
+ else if (shared.isSet(modelValue)) {
1186
+ const cloned = new Set(modelValue);
1187
+ if (checked) {
1188
+ cloned.add(elementValue);
1189
+ }
1190
+ else {
1191
+ cloned.delete(elementValue);
1192
+ }
1193
+ assign(cloned);
1194
+ }
1195
+ else {
1196
+ assign(getCheckboxValue(el, checked));
1197
+ }
1198
+ });
1199
+ },
1200
+ // set initial checked on mount to wait for true-value/false-value
1201
+ mounted: setChecked,
1202
+ beforeUpdate(el, binding, vnode) {
1203
+ el._assign = getModelAssigner(vnode);
1204
+ setChecked(el, binding, vnode);
1205
+ }
1206
+ };
1207
+ function setChecked(el, { value, oldValue }, vnode) {
1208
+ el._modelValue = value;
1209
+ if (shared.isArray(value)) {
1210
+ el.checked = shared.looseIndexOf(value, vnode.props.value) > -1;
1211
+ }
1212
+ else if (shared.isSet(value)) {
1213
+ el.checked = value.has(vnode.props.value);
1214
+ }
1215
+ else if (value !== oldValue) {
1216
+ el.checked = shared.looseEqual(value, getCheckboxValue(el, true));
1217
+ }
1218
+ }
1219
+ const vModelRadio = {
1220
+ created(el, { value }, vnode) {
1221
+ el.checked = shared.looseEqual(value, vnode.props.value);
1222
+ el._assign = getModelAssigner(vnode);
1223
+ addEventListener(el, 'change', () => {
1224
+ el._assign(getValue(el));
1225
+ });
1226
+ },
1227
+ beforeUpdate(el, { value, oldValue }, vnode) {
1228
+ el._assign = getModelAssigner(vnode);
1229
+ if (value !== oldValue) {
1230
+ el.checked = shared.looseEqual(value, vnode.props.value);
1231
+ }
1232
+ }
1233
+ };
1234
+ const vModelSelect = {
1235
+ // <select multiple> value need to be deep traversed
1236
+ deep: true,
1237
+ created(el, { value, modifiers: { number } }, vnode) {
1238
+ const isSetModel = shared.isSet(value);
1239
+ addEventListener(el, 'change', () => {
1240
+ const selectedVal = Array.prototype.filter
1241
+ .call(el.options, (o) => o.selected)
1242
+ .map((o) => number ? shared.toNumber(getValue(o)) : getValue(o));
1243
+ el._assign(el.multiple
1244
+ ? isSetModel
1245
+ ? new Set(selectedVal)
1246
+ : selectedVal
1247
+ : selectedVal[0]);
1248
+ });
1249
+ el._assign = getModelAssigner(vnode);
1250
+ },
1251
+ // set value in mounted & updated because <select> relies on its children
1252
+ // <option>s.
1253
+ mounted(el, { value }) {
1254
+ setSelected(el, value);
1255
+ },
1256
+ beforeUpdate(el, _binding, vnode) {
1257
+ el._assign = getModelAssigner(vnode);
1258
+ },
1259
+ updated(el, { value }) {
1260
+ setSelected(el, value);
1261
+ }
1262
+ };
1263
+ function setSelected(el, value) {
1264
+ const isMultiple = el.multiple;
1265
+ if (isMultiple && !shared.isArray(value) && !shared.isSet(value)) {
1266
+ runtimeCore.warn(`<select multiple v-model> expects an Array or Set value for its binding, ` +
1267
+ `but got ${Object.prototype.toString.call(value).slice(8, -1)}.`);
1268
+ return;
1269
+ }
1270
+ for (let i = 0, l = el.options.length; i < l; i++) {
1271
+ const option = el.options[i];
1272
+ const optionValue = getValue(option);
1273
+ if (isMultiple) {
1274
+ if (shared.isArray(value)) {
1275
+ option.selected = shared.looseIndexOf(value, optionValue) > -1;
1276
+ }
1277
+ else {
1278
+ option.selected = value.has(optionValue);
1279
+ }
1280
+ }
1281
+ else {
1282
+ if (shared.looseEqual(getValue(option), value)) {
1283
+ if (el.selectedIndex !== i)
1284
+ el.selectedIndex = i;
1285
+ return;
1286
+ }
1287
+ }
1288
+ }
1289
+ if (!isMultiple && el.selectedIndex !== -1) {
1290
+ el.selectedIndex = -1;
1291
+ }
1292
+ }
1293
+ // retrieve raw value set via :value bindings
1294
+ function getValue(el) {
1295
+ return '_value' in el ? el._value : el.value;
1296
+ }
1297
+ // retrieve raw value for true-value and false-value set via :true-value or :false-value bindings
1298
+ function getCheckboxValue(el, checked) {
1299
+ const key = checked ? '_trueValue' : '_falseValue';
1300
+ return key in el ? el[key] : checked;
1301
+ }
1302
+ const vModelDynamic = {
1303
+ created(el, binding, vnode) {
1304
+ callModelHook(el, binding, vnode, null, 'created');
1305
+ },
1306
+ mounted(el, binding, vnode) {
1307
+ callModelHook(el, binding, vnode, null, 'mounted');
1308
+ },
1309
+ beforeUpdate(el, binding, vnode, prevVNode) {
1310
+ callModelHook(el, binding, vnode, prevVNode, 'beforeUpdate');
1311
+ },
1312
+ updated(el, binding, vnode, prevVNode) {
1313
+ callModelHook(el, binding, vnode, prevVNode, 'updated');
1314
+ }
1315
+ };
1316
+ function resolveDynamicModel(tagName, type) {
1317
+ switch (tagName) {
1318
+ case 'SELECT':
1319
+ return vModelSelect;
1320
+ case 'TEXTAREA':
1321
+ return vModelText;
1322
+ default:
1323
+ switch (type) {
1324
+ case 'checkbox':
1325
+ return vModelCheckbox;
1326
+ case 'radio':
1327
+ return vModelRadio;
1328
+ default:
1329
+ return vModelText;
1330
+ }
1331
+ }
1332
+ }
1333
+ function callModelHook(el, binding, vnode, prevVNode, hook) {
1334
+ const modelToUse = resolveDynamicModel(el.tagName, vnode.props && vnode.props.type);
1335
+ const fn = modelToUse[hook];
1336
+ fn && fn(el, binding, vnode, prevVNode);
1337
+ }
1338
+ // SSR vnode transforms, only used when user includes client-oriented render
1339
+ // function in SSR
1340
+ function initVModelForSSR() {
1341
+ vModelText.getSSRProps = ({ value }) => ({ value });
1342
+ vModelRadio.getSSRProps = ({ value }, vnode) => {
1343
+ if (vnode.props && shared.looseEqual(vnode.props.value, value)) {
1344
+ return { checked: true };
1345
+ }
1346
+ };
1347
+ vModelCheckbox.getSSRProps = ({ value }, vnode) => {
1348
+ if (shared.isArray(value)) {
1349
+ if (vnode.props && shared.looseIndexOf(value, vnode.props.value) > -1) {
1350
+ return { checked: true };
1351
+ }
1352
+ }
1353
+ else if (shared.isSet(value)) {
1354
+ if (vnode.props && value.has(vnode.props.value)) {
1355
+ return { checked: true };
1356
+ }
1357
+ }
1358
+ else if (value) {
1359
+ return { checked: true };
1360
+ }
1361
+ };
1362
+ vModelDynamic.getSSRProps = (binding, vnode) => {
1363
+ if (typeof vnode.type !== 'string') {
1364
+ return;
1365
+ }
1366
+ const modelToUse = resolveDynamicModel(
1367
+ // resolveDynamicModel expects an uppercase tag name, but vnode.type is lowercase
1368
+ vnode.type.toUpperCase(), vnode.props && vnode.props.type);
1369
+ if (modelToUse.getSSRProps) {
1370
+ return modelToUse.getSSRProps(binding, vnode);
1371
+ }
1372
+ };
1389
1373
  }
1390
1374
 
1391
- const systemModifiers = ['ctrl', 'shift', 'alt', 'meta'];
1392
- const modifierGuards = {
1393
- stop: e => e.stopPropagation(),
1394
- prevent: e => e.preventDefault(),
1395
- self: e => e.target !== e.currentTarget,
1396
- ctrl: e => !e.ctrlKey,
1397
- shift: e => !e.shiftKey,
1398
- alt: e => !e.altKey,
1399
- meta: e => !e.metaKey,
1400
- left: e => 'button' in e && e.button !== 0,
1401
- middle: e => 'button' in e && e.button !== 1,
1402
- right: e => 'button' in e && e.button !== 2,
1403
- exact: (e, modifiers) => systemModifiers.some(m => e[`${m}Key`] && !modifiers.includes(m))
1404
- };
1405
- /**
1406
- * @private
1407
- */
1408
- const withModifiers = (fn, modifiers) => {
1409
- return (event, ...args) => {
1410
- for (let i = 0; i < modifiers.length; i++) {
1411
- const guard = modifierGuards[modifiers[i]];
1412
- if (guard && guard(event, modifiers))
1413
- return;
1414
- }
1415
- return fn(event, ...args);
1416
- };
1417
- };
1418
- // Kept for 2.x compat.
1419
- // Note: IE11 compat for `spacebar` and `del` is removed for now.
1420
- const keyNames = {
1421
- esc: 'escape',
1422
- space: ' ',
1423
- up: 'arrow-up',
1424
- left: 'arrow-left',
1425
- right: 'arrow-right',
1426
- down: 'arrow-down',
1427
- delete: 'backspace'
1428
- };
1429
- /**
1430
- * @private
1431
- */
1432
- const withKeys = (fn, modifiers) => {
1433
- return (event) => {
1434
- if (!('key' in event)) {
1435
- return;
1436
- }
1437
- const eventKey = shared.hyphenate(event.key);
1438
- if (modifiers.some(k => k === eventKey || keyNames[k] === eventKey)) {
1439
- return fn(event);
1440
- }
1441
- };
1375
+ const systemModifiers = ['ctrl', 'shift', 'alt', 'meta'];
1376
+ const modifierGuards = {
1377
+ stop: e => e.stopPropagation(),
1378
+ prevent: e => e.preventDefault(),
1379
+ self: e => e.target !== e.currentTarget,
1380
+ ctrl: e => !e.ctrlKey,
1381
+ shift: e => !e.shiftKey,
1382
+ alt: e => !e.altKey,
1383
+ meta: e => !e.metaKey,
1384
+ left: e => 'button' in e && e.button !== 0,
1385
+ middle: e => 'button' in e && e.button !== 1,
1386
+ right: e => 'button' in e && e.button !== 2,
1387
+ exact: (e, modifiers) => systemModifiers.some(m => e[`${m}Key`] && !modifiers.includes(m))
1388
+ };
1389
+ /**
1390
+ * @private
1391
+ */
1392
+ const withModifiers = (fn, modifiers) => {
1393
+ return (event, ...args) => {
1394
+ for (let i = 0; i < modifiers.length; i++) {
1395
+ const guard = modifierGuards[modifiers[i]];
1396
+ if (guard && guard(event, modifiers))
1397
+ return;
1398
+ }
1399
+ return fn(event, ...args);
1400
+ };
1401
+ };
1402
+ // Kept for 2.x compat.
1403
+ // Note: IE11 compat for `spacebar` and `del` is removed for now.
1404
+ const keyNames = {
1405
+ esc: 'escape',
1406
+ space: ' ',
1407
+ up: 'arrow-up',
1408
+ left: 'arrow-left',
1409
+ right: 'arrow-right',
1410
+ down: 'arrow-down',
1411
+ delete: 'backspace'
1412
+ };
1413
+ /**
1414
+ * @private
1415
+ */
1416
+ const withKeys = (fn, modifiers) => {
1417
+ return (event) => {
1418
+ if (!('key' in event)) {
1419
+ return;
1420
+ }
1421
+ const eventKey = shared.hyphenate(event.key);
1422
+ if (modifiers.some(k => k === eventKey || keyNames[k] === eventKey)) {
1423
+ return fn(event);
1424
+ }
1425
+ };
1442
1426
  };
1443
1427
 
1444
- const vShow = {
1445
- beforeMount(el, { value }, { transition }) {
1446
- el._vod = el.style.display === 'none' ? '' : el.style.display;
1447
- if (transition && value) {
1448
- transition.beforeEnter(el);
1449
- }
1450
- else {
1451
- setDisplay(el, value);
1452
- }
1453
- },
1454
- mounted(el, { value }, { transition }) {
1455
- if (transition && value) {
1456
- transition.enter(el);
1457
- }
1458
- },
1459
- updated(el, { value, oldValue }, { transition }) {
1460
- if (!value === !oldValue)
1461
- return;
1462
- if (transition) {
1463
- if (value) {
1464
- transition.beforeEnter(el);
1465
- setDisplay(el, true);
1466
- transition.enter(el);
1467
- }
1468
- else {
1469
- transition.leave(el, () => {
1470
- setDisplay(el, false);
1471
- });
1472
- }
1473
- }
1474
- else {
1475
- setDisplay(el, value);
1476
- }
1477
- },
1478
- beforeUnmount(el, { value }) {
1479
- setDisplay(el, value);
1480
- }
1481
- };
1482
- function setDisplay(el, value) {
1483
- el.style.display = value ? el._vod : 'none';
1484
- }
1485
- // SSR vnode transforms, only used when user includes client-oriented render
1486
- // function in SSR
1487
- function initVShowForSSR() {
1488
- vShow.getSSRProps = ({ value }) => {
1489
- if (!value) {
1490
- return { style: { display: 'none' } };
1491
- }
1492
- };
1428
+ const vShow = {
1429
+ beforeMount(el, { value }, { transition }) {
1430
+ el._vod = el.style.display === 'none' ? '' : el.style.display;
1431
+ if (transition && value) {
1432
+ transition.beforeEnter(el);
1433
+ }
1434
+ else {
1435
+ setDisplay(el, value);
1436
+ }
1437
+ },
1438
+ mounted(el, { value }, { transition }) {
1439
+ if (transition && value) {
1440
+ transition.enter(el);
1441
+ }
1442
+ },
1443
+ updated(el, { value, oldValue }, { transition }) {
1444
+ if (!value === !oldValue)
1445
+ return;
1446
+ if (transition) {
1447
+ if (value) {
1448
+ transition.beforeEnter(el);
1449
+ setDisplay(el, true);
1450
+ transition.enter(el);
1451
+ }
1452
+ else {
1453
+ transition.leave(el, () => {
1454
+ setDisplay(el, false);
1455
+ });
1456
+ }
1457
+ }
1458
+ else {
1459
+ setDisplay(el, value);
1460
+ }
1461
+ },
1462
+ beforeUnmount(el, { value }) {
1463
+ setDisplay(el, value);
1464
+ }
1465
+ };
1466
+ function setDisplay(el, value) {
1467
+ el.style.display = value ? el._vod : 'none';
1468
+ }
1469
+ // SSR vnode transforms, only used when user includes client-oriented render
1470
+ // function in SSR
1471
+ function initVShowForSSR() {
1472
+ vShow.getSSRProps = ({ value }) => {
1473
+ if (!value) {
1474
+ return { style: { display: 'none' } };
1475
+ }
1476
+ };
1493
1477
  }
1494
1478
 
1495
- const rendererOptions = /*#__PURE__*/ shared.extend({ patchProp }, nodeOps);
1496
- // lazy create the renderer - this makes core renderer logic tree-shakable
1497
- // in case the user only imports reactivity utilities from Vue.
1498
- let renderer;
1499
- let enabledHydration = false;
1500
- function ensureRenderer() {
1501
- return (renderer ||
1502
- (renderer = runtimeCore.createRenderer(rendererOptions)));
1503
- }
1504
- function ensureHydrationRenderer() {
1505
- renderer = enabledHydration
1506
- ? renderer
1507
- : runtimeCore.createHydrationRenderer(rendererOptions);
1508
- enabledHydration = true;
1509
- return renderer;
1510
- }
1511
- // use explicit type casts here to avoid import() calls in rolled-up d.ts
1512
- const render = ((...args) => {
1513
- ensureRenderer().render(...args);
1514
- });
1515
- const hydrate = ((...args) => {
1516
- ensureHydrationRenderer().hydrate(...args);
1517
- });
1518
- const createApp = ((...args) => {
1519
- const app = ensureRenderer().createApp(...args);
1520
- {
1521
- injectNativeTagCheck(app);
1522
- injectCompilerOptionsCheck(app);
1523
- }
1524
- const { mount } = app;
1525
- app.mount = (containerOrSelector) => {
1526
- const container = normalizeContainer(containerOrSelector);
1527
- if (!container)
1528
- return;
1529
- const component = app._component;
1530
- if (!shared.isFunction(component) && !component.render && !component.template) {
1531
- // __UNSAFE__
1532
- // Reason: potential execution of JS expressions in in-DOM template.
1533
- // The user must make sure the in-DOM template is trusted. If it's
1534
- // rendered by the server, the template should not contain any user data.
1535
- component.template = container.innerHTML;
1536
- }
1537
- // clear content before mounting
1538
- container.innerHTML = '';
1539
- const proxy = mount(container, false, container instanceof SVGElement);
1540
- if (container instanceof Element) {
1541
- container.removeAttribute('v-cloak');
1542
- container.setAttribute('data-v-app', '');
1543
- }
1544
- return proxy;
1545
- };
1546
- return app;
1547
- });
1548
- const createSSRApp = ((...args) => {
1549
- const app = ensureHydrationRenderer().createApp(...args);
1550
- {
1551
- injectNativeTagCheck(app);
1552
- injectCompilerOptionsCheck(app);
1553
- }
1554
- const { mount } = app;
1555
- app.mount = (containerOrSelector) => {
1556
- const container = normalizeContainer(containerOrSelector);
1557
- if (container) {
1558
- return mount(container, true, container instanceof SVGElement);
1559
- }
1560
- };
1561
- return app;
1562
- });
1563
- function injectNativeTagCheck(app) {
1564
- // Inject `isNativeTag`
1565
- // this is used for component name validation (dev only)
1566
- Object.defineProperty(app.config, 'isNativeTag', {
1567
- value: (tag) => shared.isHTMLTag(tag) || shared.isSVGTag(tag),
1568
- writable: false
1569
- });
1570
- }
1571
- // dev only
1572
- function injectCompilerOptionsCheck(app) {
1573
- if (runtimeCore.isRuntimeOnly()) {
1574
- const isCustomElement = app.config.isCustomElement;
1575
- Object.defineProperty(app.config, 'isCustomElement', {
1576
- get() {
1577
- return isCustomElement;
1578
- },
1579
- set() {
1580
- runtimeCore.warn(`The \`isCustomElement\` config option is deprecated. Use ` +
1581
- `\`compilerOptions.isCustomElement\` instead.`);
1582
- }
1583
- });
1584
- const compilerOptions = app.config.compilerOptions;
1585
- const msg = `The \`compilerOptions\` config option is only respected when using ` +
1586
- `a build of Vue.js that includes the runtime compiler (aka "full build"). ` +
1587
- `Since you are using the runtime-only build, \`compilerOptions\` ` +
1588
- `must be passed to \`@vue/compiler-dom\` in the build setup instead.\n` +
1589
- `- For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.\n` +
1590
- `- For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader\n` +
1591
- `- For vite: pass it via @vitejs/plugin-vue options. See https://github.com/vitejs/vite/tree/main/packages/plugin-vue#example-for-passing-options-to-vuecompiler-dom`;
1592
- Object.defineProperty(app.config, 'compilerOptions', {
1593
- get() {
1594
- runtimeCore.warn(msg);
1595
- return compilerOptions;
1596
- },
1597
- set() {
1598
- runtimeCore.warn(msg);
1599
- }
1600
- });
1601
- }
1602
- }
1603
- function normalizeContainer(container) {
1604
- if (shared.isString(container)) {
1605
- const res = document.querySelector(container);
1606
- if (!res) {
1607
- runtimeCore.warn(`Failed to mount app: mount target selector "${container}" returned null.`);
1608
- }
1609
- return res;
1610
- }
1611
- if (window.ShadowRoot &&
1612
- container instanceof window.ShadowRoot &&
1613
- container.mode === 'closed') {
1614
- runtimeCore.warn(`mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`);
1615
- }
1616
- return container;
1617
- }
1618
- let ssrDirectiveInitialized = false;
1619
- /**
1620
- * @internal
1621
- */
1622
- const initDirectivesForSSR = () => {
1623
- if (!ssrDirectiveInitialized) {
1624
- ssrDirectiveInitialized = true;
1625
- initVModelForSSR();
1626
- initVShowForSSR();
1627
- }
1628
- }
1479
+ const rendererOptions = /*#__PURE__*/ shared.extend({ patchProp }, nodeOps);
1480
+ // lazy create the renderer - this makes core renderer logic tree-shakable
1481
+ // in case the user only imports reactivity utilities from Vue.
1482
+ let renderer;
1483
+ let enabledHydration = false;
1484
+ function ensureRenderer() {
1485
+ return (renderer ||
1486
+ (renderer = runtimeCore.createRenderer(rendererOptions)));
1487
+ }
1488
+ function ensureHydrationRenderer() {
1489
+ renderer = enabledHydration
1490
+ ? renderer
1491
+ : runtimeCore.createHydrationRenderer(rendererOptions);
1492
+ enabledHydration = true;
1493
+ return renderer;
1494
+ }
1495
+ // use explicit type casts here to avoid import() calls in rolled-up d.ts
1496
+ const render = ((...args) => {
1497
+ ensureRenderer().render(...args);
1498
+ });
1499
+ const hydrate = ((...args) => {
1500
+ ensureHydrationRenderer().hydrate(...args);
1501
+ });
1502
+ const createApp = ((...args) => {
1503
+ const app = ensureRenderer().createApp(...args);
1504
+ {
1505
+ injectNativeTagCheck(app);
1506
+ injectCompilerOptionsCheck(app);
1507
+ }
1508
+ const { mount } = app;
1509
+ app.mount = (containerOrSelector) => {
1510
+ const container = normalizeContainer(containerOrSelector);
1511
+ if (!container)
1512
+ return;
1513
+ const component = app._component;
1514
+ if (!shared.isFunction(component) && !component.render && !component.template) {
1515
+ // __UNSAFE__
1516
+ // Reason: potential execution of JS expressions in in-DOM template.
1517
+ // The user must make sure the in-DOM template is trusted. If it's
1518
+ // rendered by the server, the template should not contain any user data.
1519
+ component.template = container.innerHTML;
1520
+ }
1521
+ // clear content before mounting
1522
+ container.innerHTML = '';
1523
+ const proxy = mount(container, false, container instanceof SVGElement);
1524
+ if (container instanceof Element) {
1525
+ container.removeAttribute('v-cloak');
1526
+ container.setAttribute('data-v-app', '');
1527
+ }
1528
+ return proxy;
1529
+ };
1530
+ return app;
1531
+ });
1532
+ const createSSRApp = ((...args) => {
1533
+ const app = ensureHydrationRenderer().createApp(...args);
1534
+ {
1535
+ injectNativeTagCheck(app);
1536
+ injectCompilerOptionsCheck(app);
1537
+ }
1538
+ const { mount } = app;
1539
+ app.mount = (containerOrSelector) => {
1540
+ const container = normalizeContainer(containerOrSelector);
1541
+ if (container) {
1542
+ return mount(container, true, container instanceof SVGElement);
1543
+ }
1544
+ };
1545
+ return app;
1546
+ });
1547
+ function injectNativeTagCheck(app) {
1548
+ // Inject `isNativeTag`
1549
+ // this is used for component name validation (dev only)
1550
+ Object.defineProperty(app.config, 'isNativeTag', {
1551
+ value: (tag) => shared.isHTMLTag(tag) || shared.isSVGTag(tag),
1552
+ writable: false
1553
+ });
1554
+ }
1555
+ // dev only
1556
+ function injectCompilerOptionsCheck(app) {
1557
+ if (runtimeCore.isRuntimeOnly()) {
1558
+ const isCustomElement = app.config.isCustomElement;
1559
+ Object.defineProperty(app.config, 'isCustomElement', {
1560
+ get() {
1561
+ return isCustomElement;
1562
+ },
1563
+ set() {
1564
+ runtimeCore.warn(`The \`isCustomElement\` config option is deprecated. Use ` +
1565
+ `\`compilerOptions.isCustomElement\` instead.`);
1566
+ }
1567
+ });
1568
+ const compilerOptions = app.config.compilerOptions;
1569
+ const msg = `The \`compilerOptions\` config option is only respected when using ` +
1570
+ `a build of Vue.js that includes the runtime compiler (aka "full build"). ` +
1571
+ `Since you are using the runtime-only build, \`compilerOptions\` ` +
1572
+ `must be passed to \`@vue/compiler-dom\` in the build setup instead.\n` +
1573
+ `- For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.\n` +
1574
+ `- For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader\n` +
1575
+ `- For vite: pass it via @vitejs/plugin-vue options. See https://github.com/vitejs/vite/tree/main/packages/plugin-vue#example-for-passing-options-to-vuecompiler-dom`;
1576
+ Object.defineProperty(app.config, 'compilerOptions', {
1577
+ get() {
1578
+ runtimeCore.warn(msg);
1579
+ return compilerOptions;
1580
+ },
1581
+ set() {
1582
+ runtimeCore.warn(msg);
1583
+ }
1584
+ });
1585
+ }
1586
+ }
1587
+ function normalizeContainer(container) {
1588
+ if (shared.isString(container)) {
1589
+ const res = document.querySelector(container);
1590
+ if (!res) {
1591
+ runtimeCore.warn(`Failed to mount app: mount target selector "${container}" returned null.`);
1592
+ }
1593
+ return res;
1594
+ }
1595
+ if (window.ShadowRoot &&
1596
+ container instanceof window.ShadowRoot &&
1597
+ container.mode === 'closed') {
1598
+ runtimeCore.warn(`mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`);
1599
+ }
1600
+ return container;
1601
+ }
1602
+ let ssrDirectiveInitialized = false;
1603
+ /**
1604
+ * @internal
1605
+ */
1606
+ const initDirectivesForSSR = () => {
1607
+ if (!ssrDirectiveInitialized) {
1608
+ ssrDirectiveInitialized = true;
1609
+ initVModelForSSR();
1610
+ initVShowForSSR();
1611
+ }
1612
+ }
1629
1613
  ;
1630
1614
 
1631
1615
  Object.keys(runtimeCore).forEach(function (k) {