@vue/runtime-dom 3.2.46 → 3.3.0-alpha.1

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