@shijiu/jsview 1.9.760 → 1.9.779

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