@vue/runtime-dom 3.2.40 → 3.2.42

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