@tarojs/components-advanced 3.6.3 → 3.6.5-alpha

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