source: node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.js@ 7deb3e2

Last change on this file since 7deb3e2 was 57e58a3, checked in by ste08 <sjovanoska@…>, 4 months ago

Initial commit

  • Property mode set to 100644
File size: 54.0 KB
Line 
1/**
2* @vue/runtime-dom v3.5.13
3* (c) 2018-present Yuxi (Evan) You and Vue contributors
4* @license MIT
5**/
6'use strict';
7
8Object.defineProperty(exports, '__esModule', { value: true });
9
10var runtimeCore = require('@vue/runtime-core');
11var shared = require('@vue/shared');
12
13let policy = void 0;
14const tt = typeof window !== "undefined" && window.trustedTypes;
15if (tt) {
16 try {
17 policy = /* @__PURE__ */ tt.createPolicy("vue", {
18 createHTML: (val) => val
19 });
20 } catch (e) {
21 runtimeCore.warn(`Error creating trusted types policy: ${e}`);
22 }
23}
24const unsafeToTrustedHTML = policy ? (val) => policy.createHTML(val) : (val) => val;
25const svgNS = "http://www.w3.org/2000/svg";
26const mathmlNS = "http://www.w3.org/1998/Math/MathML";
27const doc = typeof document !== "undefined" ? document : null;
28const templateContainer = doc && /* @__PURE__ */ doc.createElement("template");
29const nodeOps = {
30 insert: (child, parent, anchor) => {
31 parent.insertBefore(child, anchor || null);
32 },
33 remove: (child) => {
34 const parent = child.parentNode;
35 if (parent) {
36 parent.removeChild(child);
37 }
38 },
39 createElement: (tag, namespace, is, props) => {
40 const el = namespace === "svg" ? doc.createElementNS(svgNS, tag) : namespace === "mathml" ? doc.createElementNS(mathmlNS, tag) : is ? doc.createElement(tag, { is }) : doc.createElement(tag);
41 if (tag === "select" && props && props.multiple != null) {
42 el.setAttribute("multiple", props.multiple);
43 }
44 return el;
45 },
46 createText: (text) => doc.createTextNode(text),
47 createComment: (text) => doc.createComment(text),
48 setText: (node, text) => {
49 node.nodeValue = text;
50 },
51 setElementText: (el, text) => {
52 el.textContent = text;
53 },
54 parentNode: (node) => node.parentNode,
55 nextSibling: (node) => node.nextSibling,
56 querySelector: (selector) => doc.querySelector(selector),
57 setScopeId(el, id) {
58 el.setAttribute(id, "");
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, namespace, start, end) {
65 const before = anchor ? anchor.previousSibling : parent.lastChild;
66 if (start && (start === end || start.nextSibling)) {
67 while (true) {
68 parent.insertBefore(start.cloneNode(true), anchor);
69 if (start === end || !(start = start.nextSibling)) break;
70 }
71 } else {
72 templateContainer.innerHTML = unsafeToTrustedHTML(
73 namespace === "svg" ? `<svg>${content}</svg>` : namespace === "mathml" ? `<math>${content}</math>` : content
74 );
75 const template = templateContainer.content;
76 if (namespace === "svg" || namespace === "mathml") {
77 const wrapper = template.firstChild;
78 while (wrapper.firstChild) {
79 template.appendChild(wrapper.firstChild);
80 }
81 template.removeChild(wrapper);
82 }
83 parent.insertBefore(template, anchor);
84 }
85 return [
86 // first
87 before ? before.nextSibling : parent.firstChild,
88 // last
89 anchor ? anchor.previousSibling : parent.lastChild
90 ];
91 }
92};
93
94const TRANSITION = "transition";
95const ANIMATION = "animation";
96const vtcKey = Symbol("_vtc");
97const DOMTransitionPropsValidators = {
98 name: String,
99 type: String,
100 css: {
101 type: Boolean,
102 default: true
103 },
104 duration: [String, Number, Object],
105 enterFromClass: String,
106 enterActiveClass: String,
107 enterToClass: String,
108 appearFromClass: String,
109 appearActiveClass: String,
110 appearToClass: String,
111 leaveFromClass: String,
112 leaveActiveClass: String,
113 leaveToClass: String
114};
115const TransitionPropsValidators = /* @__PURE__ */ shared.extend(
116 {},
117 runtimeCore.BaseTransitionPropsValidators,
118 DOMTransitionPropsValidators
119);
120const decorate$1 = (t) => {
121 t.displayName = "Transition";
122 t.props = TransitionPropsValidators;
123 return t;
124};
125const Transition = /* @__PURE__ */ decorate$1(
126 (props, { slots }) => runtimeCore.h(runtimeCore.BaseTransition, resolveTransitionProps(props), slots)
127);
128const callHook = (hook, args = []) => {
129 if (shared.isArray(hook)) {
130 hook.forEach((h2) => h2(...args));
131 } else if (hook) {
132 hook(...args);
133 }
134};
135const hasExplicitCallback = (hook) => {
136 return hook ? shared.isArray(hook) ? hook.some((h2) => h2.length > 1) : hook.length > 1 : false;
137};
138function resolveTransitionProps(rawProps) {
139 const baseProps = {};
140 for (const key in rawProps) {
141 if (!(key in DOMTransitionPropsValidators)) {
142 baseProps[key] = rawProps[key];
143 }
144 }
145 if (rawProps.css === false) {
146 return baseProps;
147 }
148 const {
149 name = "v",
150 type,
151 duration,
152 enterFromClass = `${name}-enter-from`,
153 enterActiveClass = `${name}-enter-active`,
154 enterToClass = `${name}-enter-to`,
155 appearFromClass = enterFromClass,
156 appearActiveClass = enterActiveClass,
157 appearToClass = enterToClass,
158 leaveFromClass = `${name}-leave-from`,
159 leaveActiveClass = `${name}-leave-active`,
160 leaveToClass = `${name}-leave-to`
161 } = rawProps;
162 const durations = normalizeDuration(duration);
163 const enterDuration = durations && durations[0];
164 const leaveDuration = durations && durations[1];
165 const {
166 onBeforeEnter,
167 onEnter,
168 onEnterCancelled,
169 onLeave,
170 onLeaveCancelled,
171 onBeforeAppear = onBeforeEnter,
172 onAppear = onEnter,
173 onAppearCancelled = onEnterCancelled
174 } = baseProps;
175 const finishEnter = (el, isAppear, done, isCancelled) => {
176 el._enterCancelled = isCancelled;
177 removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
178 removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
179 done && done();
180 };
181 const finishLeave = (el, done) => {
182 el._isLeaving = false;
183 removeTransitionClass(el, leaveFromClass);
184 removeTransitionClass(el, leaveToClass);
185 removeTransitionClass(el, leaveActiveClass);
186 done && done();
187 };
188 const makeEnterHook = (isAppear) => {
189 return (el, done) => {
190 const hook = isAppear ? onAppear : onEnter;
191 const resolve = () => finishEnter(el, isAppear, done);
192 callHook(hook, [el, resolve]);
193 nextFrame(() => {
194 removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
195 addTransitionClass(el, isAppear ? appearToClass : enterToClass);
196 if (!hasExplicitCallback(hook)) {
197 whenTransitionEnds(el, type, enterDuration, resolve);
198 }
199 });
200 };
201 };
202 return shared.extend(baseProps, {
203 onBeforeEnter(el) {
204 callHook(onBeforeEnter, [el]);
205 addTransitionClass(el, enterFromClass);
206 addTransitionClass(el, enterActiveClass);
207 },
208 onBeforeAppear(el) {
209 callHook(onBeforeAppear, [el]);
210 addTransitionClass(el, appearFromClass);
211 addTransitionClass(el, appearActiveClass);
212 },
213 onEnter: makeEnterHook(false),
214 onAppear: makeEnterHook(true),
215 onLeave(el, done) {
216 el._isLeaving = true;
217 const resolve = () => finishLeave(el, done);
218 addTransitionClass(el, leaveFromClass);
219 if (!el._enterCancelled) {
220 forceReflow();
221 addTransitionClass(el, leaveActiveClass);
222 } else {
223 addTransitionClass(el, leaveActiveClass);
224 forceReflow();
225 }
226 nextFrame(() => {
227 if (!el._isLeaving) {
228 return;
229 }
230 removeTransitionClass(el, leaveFromClass);
231 addTransitionClass(el, leaveToClass);
232 if (!hasExplicitCallback(onLeave)) {
233 whenTransitionEnds(el, type, leaveDuration, resolve);
234 }
235 });
236 callHook(onLeave, [el, resolve]);
237 },
238 onEnterCancelled(el) {
239 finishEnter(el, false, void 0, true);
240 callHook(onEnterCancelled, [el]);
241 },
242 onAppearCancelled(el) {
243 finishEnter(el, true, void 0, true);
244 callHook(onAppearCancelled, [el]);
245 },
246 onLeaveCancelled(el) {
247 finishLeave(el);
248 callHook(onLeaveCancelled, [el]);
249 }
250 });
251}
252function normalizeDuration(duration) {
253 if (duration == null) {
254 return null;
255 } else if (shared.isObject(duration)) {
256 return [NumberOf(duration.enter), NumberOf(duration.leave)];
257 } else {
258 const n = NumberOf(duration);
259 return [n, n];
260 }
261}
262function NumberOf(val) {
263 const res = shared.toNumber(val);
264 {
265 runtimeCore.assertNumber(res, "<transition> explicit duration");
266 }
267 return res;
268}
269function addTransitionClass(el, cls) {
270 cls.split(/\s+/).forEach((c) => c && el.classList.add(c));
271 (el[vtcKey] || (el[vtcKey] = /* @__PURE__ */ new Set())).add(cls);
272}
273function removeTransitionClass(el, cls) {
274 cls.split(/\s+/).forEach((c) => c && el.classList.remove(c));
275 const _vtc = el[vtcKey];
276 if (_vtc) {
277 _vtc.delete(cls);
278 if (!_vtc.size) {
279 el[vtcKey] = void 0;
280 }
281 }
282}
283function nextFrame(cb) {
284 requestAnimationFrame(() => {
285 requestAnimationFrame(cb);
286 });
287}
288let endId = 0;
289function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
290 const id = el._endId = ++endId;
291 const resolveIfNotStale = () => {
292 if (id === el._endId) {
293 resolve();
294 }
295 };
296 if (explicitTimeout != null) {
297 return setTimeout(resolveIfNotStale, explicitTimeout);
298 }
299 const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
300 if (!type) {
301 return resolve();
302 }
303 const endEvent = type + "end";
304 let ended = 0;
305 const end = () => {
306 el.removeEventListener(endEvent, onEnd);
307 resolveIfNotStale();
308 };
309 const onEnd = (e) => {
310 if (e.target === el && ++ended >= propCount) {
311 end();
312 }
313 };
314 setTimeout(() => {
315 if (ended < propCount) {
316 end();
317 }
318 }, timeout + 1);
319 el.addEventListener(endEvent, onEnd);
320}
321function getTransitionInfo(el, expectedType) {
322 const styles = window.getComputedStyle(el);
323 const getStyleProperties = (key) => (styles[key] || "").split(", ");
324 const transitionDelays = getStyleProperties(`${TRANSITION}Delay`);
325 const transitionDurations = getStyleProperties(`${TRANSITION}Duration`);
326 const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
327 const animationDelays = getStyleProperties(`${ANIMATION}Delay`);
328 const animationDurations = getStyleProperties(`${ANIMATION}Duration`);
329 const animationTimeout = getTimeout(animationDelays, animationDurations);
330 let type = null;
331 let timeout = 0;
332 let propCount = 0;
333 if (expectedType === TRANSITION) {
334 if (transitionTimeout > 0) {
335 type = TRANSITION;
336 timeout = transitionTimeout;
337 propCount = transitionDurations.length;
338 }
339 } else if (expectedType === ANIMATION) {
340 if (animationTimeout > 0) {
341 type = ANIMATION;
342 timeout = animationTimeout;
343 propCount = animationDurations.length;
344 }
345 } else {
346 timeout = Math.max(transitionTimeout, animationTimeout);
347 type = timeout > 0 ? transitionTimeout > animationTimeout ? TRANSITION : ANIMATION : null;
348 propCount = type ? type === TRANSITION ? transitionDurations.length : animationDurations.length : 0;
349 }
350 const hasTransform = type === TRANSITION && /\b(transform|all)(,|$)/.test(
351 getStyleProperties(`${TRANSITION}Property`).toString()
352 );
353 return {
354 type,
355 timeout,
356 propCount,
357 hasTransform
358 };
359}
360function getTimeout(delays, durations) {
361 while (delays.length < durations.length) {
362 delays = delays.concat(delays);
363 }
364 return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
365}
366function toMs(s) {
367 if (s === "auto") return 0;
368 return Number(s.slice(0, -1).replace(",", ".")) * 1e3;
369}
370function forceReflow() {
371 return document.body.offsetHeight;
372}
373
374function patchClass(el, value, isSVG) {
375 const transitionClasses = el[vtcKey];
376 if (transitionClasses) {
377 value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(" ");
378 }
379 if (value == null) {
380 el.removeAttribute("class");
381 } else if (isSVG) {
382 el.setAttribute("class", value);
383 } else {
384 el.className = value;
385 }
386}
387
388const vShowOriginalDisplay = Symbol("_vod");
389const vShowHidden = Symbol("_vsh");
390const vShow = {
391 beforeMount(el, { value }, { transition }) {
392 el[vShowOriginalDisplay] = el.style.display === "none" ? "" : el.style.display;
393 if (transition && value) {
394 transition.beforeEnter(el);
395 } else {
396 setDisplay(el, value);
397 }
398 },
399 mounted(el, { value }, { transition }) {
400 if (transition && value) {
401 transition.enter(el);
402 }
403 },
404 updated(el, { value, oldValue }, { transition }) {
405 if (!value === !oldValue) return;
406 if (transition) {
407 if (value) {
408 transition.beforeEnter(el);
409 setDisplay(el, true);
410 transition.enter(el);
411 } else {
412 transition.leave(el, () => {
413 setDisplay(el, false);
414 });
415 }
416 } else {
417 setDisplay(el, value);
418 }
419 },
420 beforeUnmount(el, { value }) {
421 setDisplay(el, value);
422 }
423};
424{
425 vShow.name = "show";
426}
427function setDisplay(el, value) {
428 el.style.display = value ? el[vShowOriginalDisplay] : "none";
429 el[vShowHidden] = !value;
430}
431function initVShowForSSR() {
432 vShow.getSSRProps = ({ value }) => {
433 if (!value) {
434 return { style: { display: "none" } };
435 }
436 };
437}
438
439const CSS_VAR_TEXT = Symbol("CSS_VAR_TEXT" );
440function useCssVars(getter) {
441 return;
442}
443
444const displayRE = /(^|;)\s*display\s*:/;
445function patchStyle(el, prev, next) {
446 const style = el.style;
447 const isCssString = shared.isString(next);
448 let hasControlledDisplay = false;
449 if (next && !isCssString) {
450 if (prev) {
451 if (!shared.isString(prev)) {
452 for (const key in prev) {
453 if (next[key] == null) {
454 setStyle(style, key, "");
455 }
456 }
457 } else {
458 for (const prevStyle of prev.split(";")) {
459 const key = prevStyle.slice(0, prevStyle.indexOf(":")).trim();
460 if (next[key] == null) {
461 setStyle(style, key, "");
462 }
463 }
464 }
465 }
466 for (const key in next) {
467 if (key === "display") {
468 hasControlledDisplay = true;
469 }
470 setStyle(style, key, next[key]);
471 }
472 } else {
473 if (isCssString) {
474 if (prev !== next) {
475 const cssVarText = style[CSS_VAR_TEXT];
476 if (cssVarText) {
477 next += ";" + cssVarText;
478 }
479 style.cssText = next;
480 hasControlledDisplay = displayRE.test(next);
481 }
482 } else if (prev) {
483 el.removeAttribute("style");
484 }
485 }
486 if (vShowOriginalDisplay in el) {
487 el[vShowOriginalDisplay] = hasControlledDisplay ? style.display : "";
488 if (el[vShowHidden]) {
489 style.display = "none";
490 }
491 }
492}
493const semicolonRE = /[^\\];\s*$/;
494const importantRE = /\s*!important$/;
495function setStyle(style, name, val) {
496 if (shared.isArray(val)) {
497 val.forEach((v) => setStyle(style, name, v));
498 } else {
499 if (val == null) val = "";
500 {
501 if (semicolonRE.test(val)) {
502 runtimeCore.warn(
503 `Unexpected semicolon at the end of '${name}' style value: '${val}'`
504 );
505 }
506 }
507 if (name.startsWith("--")) {
508 style.setProperty(name, val);
509 } else {
510 const prefixed = autoPrefix(style, name);
511 if (importantRE.test(val)) {
512 style.setProperty(
513 shared.hyphenate(prefixed),
514 val.replace(importantRE, ""),
515 "important"
516 );
517 } else {
518 style[prefixed] = val;
519 }
520 }
521 }
522}
523const prefixes = ["Webkit", "Moz", "ms"];
524const prefixCache = {};
525function autoPrefix(style, rawName) {
526 const cached = prefixCache[rawName];
527 if (cached) {
528 return cached;
529 }
530 let name = runtimeCore.camelize(rawName);
531 if (name !== "filter" && name in style) {
532 return prefixCache[rawName] = name;
533 }
534 name = shared.capitalize(name);
535 for (let i = 0; i < prefixes.length; i++) {
536 const prefixed = prefixes[i] + name;
537 if (prefixed in style) {
538 return prefixCache[rawName] = prefixed;
539 }
540 }
541 return rawName;
542}
543
544const xlinkNS = "http://www.w3.org/1999/xlink";
545function patchAttr(el, key, value, isSVG, instance, isBoolean = shared.isSpecialBooleanAttr(key)) {
546 if (isSVG && key.startsWith("xlink:")) {
547 if (value == null) {
548 el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
549 } else {
550 el.setAttributeNS(xlinkNS, key, value);
551 }
552 } else {
553 if (value == null || isBoolean && !shared.includeBooleanAttr(value)) {
554 el.removeAttribute(key);
555 } else {
556 el.setAttribute(
557 key,
558 isBoolean ? "" : shared.isSymbol(value) ? String(value) : value
559 );
560 }
561 }
562}
563
564function patchDOMProp(el, key, value, parentComponent, attrName) {
565 if (key === "innerHTML" || key === "textContent") {
566 if (value != null) {
567 el[key] = key === "innerHTML" ? unsafeToTrustedHTML(value) : value;
568 }
569 return;
570 }
571 const tag = el.tagName;
572 if (key === "value" && tag !== "PROGRESS" && // custom elements may use _value internally
573 !tag.includes("-")) {
574 const oldValue = tag === "OPTION" ? el.getAttribute("value") || "" : el.value;
575 const newValue = value == null ? (
576 // #11647: value should be set as empty string for null and undefined,
577 // but <input type="checkbox"> should be set as 'on'.
578 el.type === "checkbox" ? "on" : ""
579 ) : String(value);
580 if (oldValue !== newValue || !("_value" in el)) {
581 el.value = newValue;
582 }
583 if (value == null) {
584 el.removeAttribute(key);
585 }
586 el._value = value;
587 return;
588 }
589 let needRemove = false;
590 if (value === "" || value == null) {
591 const type = typeof el[key];
592 if (type === "boolean") {
593 value = shared.includeBooleanAttr(value);
594 } else if (value == null && type === "string") {
595 value = "";
596 needRemove = true;
597 } else if (type === "number") {
598 value = 0;
599 needRemove = true;
600 }
601 }
602 try {
603 el[key] = value;
604 } catch (e) {
605 if (!needRemove) {
606 runtimeCore.warn(
607 `Failed setting prop "${key}" on <${tag.toLowerCase()}>: value ${value} is invalid.`,
608 e
609 );
610 }
611 }
612 needRemove && el.removeAttribute(attrName || key);
613}
614
615function addEventListener(el, event, handler, options) {
616 el.addEventListener(event, handler, options);
617}
618function removeEventListener(el, event, handler, options) {
619 el.removeEventListener(event, handler, options);
620}
621const veiKey = Symbol("_vei");
622function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
623 const invokers = el[veiKey] || (el[veiKey] = {});
624 const existingInvoker = invokers[rawName];
625 if (nextValue && existingInvoker) {
626 existingInvoker.value = sanitizeEventValue(nextValue, rawName) ;
627 } else {
628 const [name, options] = parseName(rawName);
629 if (nextValue) {
630 const invoker = invokers[rawName] = createInvoker(
631 sanitizeEventValue(nextValue, rawName) ,
632 instance
633 );
634 addEventListener(el, name, invoker, options);
635 } else if (existingInvoker) {
636 removeEventListener(el, name, existingInvoker, options);
637 invokers[rawName] = void 0;
638 }
639 }
640}
641const optionsModifierRE = /(?:Once|Passive|Capture)$/;
642function parseName(name) {
643 let options;
644 if (optionsModifierRE.test(name)) {
645 options = {};
646 let m;
647 while (m = name.match(optionsModifierRE)) {
648 name = name.slice(0, name.length - m[0].length);
649 options[m[0].toLowerCase()] = true;
650 }
651 }
652 const event = name[2] === ":" ? name.slice(3) : shared.hyphenate(name.slice(2));
653 return [event, options];
654}
655let cachedNow = 0;
656const p = /* @__PURE__ */ Promise.resolve();
657const getNow = () => cachedNow || (p.then(() => cachedNow = 0), cachedNow = Date.now());
658function createInvoker(initialValue, instance) {
659 const invoker = (e) => {
660 if (!e._vts) {
661 e._vts = Date.now();
662 } else if (e._vts <= invoker.attached) {
663 return;
664 }
665 runtimeCore.callWithAsyncErrorHandling(
666 patchStopImmediatePropagation(e, invoker.value),
667 instance,
668 5,
669 [e]
670 );
671 };
672 invoker.value = initialValue;
673 invoker.attached = getNow();
674 return invoker;
675}
676function sanitizeEventValue(value, propName) {
677 if (shared.isFunction(value) || shared.isArray(value)) {
678 return value;
679 }
680 runtimeCore.warn(
681 `Wrong type passed as event handler to ${propName} - did you forget @ or : in front of your prop?
682Expected function or array of functions, received type ${typeof value}.`
683 );
684 return shared.NOOP;
685}
686function patchStopImmediatePropagation(e, value) {
687 if (shared.isArray(value)) {
688 const originalStop = e.stopImmediatePropagation;
689 e.stopImmediatePropagation = () => {
690 originalStop.call(e);
691 e._stopped = true;
692 };
693 return value.map(
694 (fn) => (e2) => !e2._stopped && fn && fn(e2)
695 );
696 } else {
697 return value;
698 }
699}
700
701const isNativeOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // lowercase letter
702key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123;
703const patchProp = (el, key, prevValue, nextValue, namespace, parentComponent) => {
704 const isSVG = namespace === "svg";
705 if (key === "class") {
706 patchClass(el, nextValue, isSVG);
707 } else if (key === "style") {
708 patchStyle(el, prevValue, nextValue);
709 } else if (shared.isOn(key)) {
710 if (!shared.isModelListener(key)) {
711 patchEvent(el, key, prevValue, nextValue, parentComponent);
712 }
713 } else if (key[0] === "." ? (key = key.slice(1), true) : key[0] === "^" ? (key = key.slice(1), false) : shouldSetAsProp(el, key, nextValue, isSVG)) {
714 patchDOMProp(el, key, nextValue);
715 if (!el.tagName.includes("-") && (key === "value" || key === "checked" || key === "selected")) {
716 patchAttr(el, key, nextValue, isSVG, parentComponent, key !== "value");
717 }
718 } else if (
719 // #11081 force set props for possible async custom element
720 el._isVueCE && (/[A-Z]/.test(key) || !shared.isString(nextValue))
721 ) {
722 patchDOMProp(el, shared.camelize(key), nextValue, parentComponent, key);
723 } else {
724 if (key === "true-value") {
725 el._trueValue = nextValue;
726 } else if (key === "false-value") {
727 el._falseValue = nextValue;
728 }
729 patchAttr(el, key, nextValue, isSVG);
730 }
731};
732function shouldSetAsProp(el, key, value, isSVG) {
733 if (isSVG) {
734 if (key === "innerHTML" || key === "textContent") {
735 return true;
736 }
737 if (key in el && isNativeOn(key) && shared.isFunction(value)) {
738 return true;
739 }
740 return false;
741 }
742 if (key === "spellcheck" || key === "draggable" || key === "translate") {
743 return false;
744 }
745 if (key === "form") {
746 return false;
747 }
748 if (key === "list" && el.tagName === "INPUT") {
749 return false;
750 }
751 if (key === "type" && el.tagName === "TEXTAREA") {
752 return false;
753 }
754 if (key === "width" || key === "height") {
755 const tag = el.tagName;
756 if (tag === "IMG" || tag === "VIDEO" || tag === "CANVAS" || tag === "SOURCE") {
757 return false;
758 }
759 }
760 if (isNativeOn(key) && shared.isString(value)) {
761 return false;
762 }
763 return key in el;
764}
765
766const REMOVAL = {};
767/*! #__NO_SIDE_EFFECTS__ */
768// @__NO_SIDE_EFFECTS__
769function defineCustomElement(options, extraOptions, _createApp) {
770 const Comp = runtimeCore.defineComponent(options, extraOptions);
771 if (shared.isPlainObject(Comp)) shared.extend(Comp, extraOptions);
772 class VueCustomElement extends VueElement {
773 constructor(initialProps) {
774 super(Comp, initialProps, _createApp);
775 }
776 }
777 VueCustomElement.def = Comp;
778 return VueCustomElement;
779}
780/*! #__NO_SIDE_EFFECTS__ */
781const defineSSRCustomElement = /* @__NO_SIDE_EFFECTS__ */ (options, extraOptions) => {
782 return /* @__PURE__ */ defineCustomElement(options, extraOptions, createSSRApp);
783};
784const BaseClass = typeof HTMLElement !== "undefined" ? HTMLElement : class {
785};
786class VueElement extends BaseClass {
787 constructor(_def, _props = {}, _createApp = createApp) {
788 super();
789 this._def = _def;
790 this._props = _props;
791 this._createApp = _createApp;
792 this._isVueCE = true;
793 /**
794 * @internal
795 */
796 this._instance = null;
797 /**
798 * @internal
799 */
800 this._app = null;
801 /**
802 * @internal
803 */
804 this._nonce = this._def.nonce;
805 this._connected = false;
806 this._resolved = false;
807 this._numberProps = null;
808 this._styleChildren = /* @__PURE__ */ new WeakSet();
809 this._ob = null;
810 if (this.shadowRoot && _createApp !== createApp) {
811 this._root = this.shadowRoot;
812 } else {
813 if (this.shadowRoot) {
814 runtimeCore.warn(
815 `Custom element has pre-rendered declarative shadow root but is not defined as hydratable. Use \`defineSSRCustomElement\`.`
816 );
817 }
818 if (_def.shadowRoot !== false) {
819 this.attachShadow({ mode: "open" });
820 this._root = this.shadowRoot;
821 } else {
822 this._root = this;
823 }
824 }
825 if (!this._def.__asyncLoader) {
826 this._resolveProps(this._def);
827 }
828 }
829 connectedCallback() {
830 if (!this.isConnected) return;
831 if (!this.shadowRoot) {
832 this._parseSlots();
833 }
834 this._connected = true;
835 let parent = this;
836 while (parent = parent && (parent.parentNode || parent.host)) {
837 if (parent instanceof VueElement) {
838 this._parent = parent;
839 break;
840 }
841 }
842 if (!this._instance) {
843 if (this._resolved) {
844 this._setParent();
845 this._update();
846 } else {
847 if (parent && parent._pendingResolve) {
848 this._pendingResolve = parent._pendingResolve.then(() => {
849 this._pendingResolve = void 0;
850 this._resolveDef();
851 });
852 } else {
853 this._resolveDef();
854 }
855 }
856 }
857 }
858 _setParent(parent = this._parent) {
859 if (parent) {
860 this._instance.parent = parent._instance;
861 this._instance.provides = parent._instance.provides;
862 }
863 }
864 disconnectedCallback() {
865 this._connected = false;
866 runtimeCore.nextTick(() => {
867 if (!this._connected) {
868 if (this._ob) {
869 this._ob.disconnect();
870 this._ob = null;
871 }
872 this._app && this._app.unmount();
873 if (this._instance) this._instance.ce = void 0;
874 this._app = this._instance = null;
875 }
876 });
877 }
878 /**
879 * resolve inner component definition (handle possible async component)
880 */
881 _resolveDef() {
882 if (this._pendingResolve) {
883 return;
884 }
885 for (let i = 0; i < this.attributes.length; i++) {
886 this._setAttr(this.attributes[i].name);
887 }
888 this._ob = new MutationObserver((mutations) => {
889 for (const m of mutations) {
890 this._setAttr(m.attributeName);
891 }
892 });
893 this._ob.observe(this, { attributes: true });
894 const resolve = (def, isAsync = false) => {
895 this._resolved = true;
896 this._pendingResolve = void 0;
897 const { props, styles } = def;
898 let numberProps;
899 if (props && !shared.isArray(props)) {
900 for (const key in props) {
901 const opt = props[key];
902 if (opt === Number || opt && opt.type === Number) {
903 if (key in this._props) {
904 this._props[key] = shared.toNumber(this._props[key]);
905 }
906 (numberProps || (numberProps = /* @__PURE__ */ Object.create(null)))[shared.camelize(key)] = true;
907 }
908 }
909 }
910 this._numberProps = numberProps;
911 if (isAsync) {
912 this._resolveProps(def);
913 }
914 if (this.shadowRoot) {
915 this._applyStyles(styles);
916 } else if (styles) {
917 runtimeCore.warn(
918 "Custom element style injection is not supported when using shadowRoot: false"
919 );
920 }
921 this._mount(def);
922 };
923 const asyncDef = this._def.__asyncLoader;
924 if (asyncDef) {
925 this._pendingResolve = asyncDef().then(
926 (def) => resolve(this._def = def, true)
927 );
928 } else {
929 resolve(this._def);
930 }
931 }
932 _mount(def) {
933 if (!def.name) {
934 def.name = "VueElement";
935 }
936 this._app = this._createApp(def);
937 if (def.configureApp) {
938 def.configureApp(this._app);
939 }
940 this._app._ceVNode = this._createVNode();
941 this._app.mount(this._root);
942 const exposed = this._instance && this._instance.exposed;
943 if (!exposed) return;
944 for (const key in exposed) {
945 if (!shared.hasOwn(this, key)) {
946 Object.defineProperty(this, key, {
947 // unwrap ref to be consistent with public instance behavior
948 get: () => runtimeCore.unref(exposed[key])
949 });
950 } else {
951 runtimeCore.warn(`Exposed property "${key}" already exists on custom element.`);
952 }
953 }
954 }
955 _resolveProps(def) {
956 const { props } = def;
957 const declaredPropKeys = shared.isArray(props) ? props : Object.keys(props || {});
958 for (const key of Object.keys(this)) {
959 if (key[0] !== "_" && declaredPropKeys.includes(key)) {
960 this._setProp(key, this[key]);
961 }
962 }
963 for (const key of declaredPropKeys.map(shared.camelize)) {
964 Object.defineProperty(this, key, {
965 get() {
966 return this._getProp(key);
967 },
968 set(val) {
969 this._setProp(key, val, true, true);
970 }
971 });
972 }
973 }
974 _setAttr(key) {
975 if (key.startsWith("data-v-")) return;
976 const has = this.hasAttribute(key);
977 let value = has ? this.getAttribute(key) : REMOVAL;
978 const camelKey = shared.camelize(key);
979 if (has && this._numberProps && this._numberProps[camelKey]) {
980 value = shared.toNumber(value);
981 }
982 this._setProp(camelKey, value, false, true);
983 }
984 /**
985 * @internal
986 */
987 _getProp(key) {
988 return this._props[key];
989 }
990 /**
991 * @internal
992 */
993 _setProp(key, val, shouldReflect = true, shouldUpdate = false) {
994 if (val !== this._props[key]) {
995 if (val === REMOVAL) {
996 delete this._props[key];
997 } else {
998 this._props[key] = val;
999 if (key === "key" && this._app) {
1000 this._app._ceVNode.key = val;
1001 }
1002 }
1003 if (shouldUpdate && this._instance) {
1004 this._update();
1005 }
1006 if (shouldReflect) {
1007 const ob = this._ob;
1008 ob && ob.disconnect();
1009 if (val === true) {
1010 this.setAttribute(shared.hyphenate(key), "");
1011 } else if (typeof val === "string" || typeof val === "number") {
1012 this.setAttribute(shared.hyphenate(key), val + "");
1013 } else if (!val) {
1014 this.removeAttribute(shared.hyphenate(key));
1015 }
1016 ob && ob.observe(this, { attributes: true });
1017 }
1018 }
1019 }
1020 _update() {
1021 render(this._createVNode(), this._root);
1022 }
1023 _createVNode() {
1024 const baseProps = {};
1025 if (!this.shadowRoot) {
1026 baseProps.onVnodeMounted = baseProps.onVnodeUpdated = this._renderSlots.bind(this);
1027 }
1028 const vnode = runtimeCore.createVNode(this._def, shared.extend(baseProps, this._props));
1029 if (!this._instance) {
1030 vnode.ce = (instance) => {
1031 this._instance = instance;
1032 instance.ce = this;
1033 instance.isCE = true;
1034 {
1035 instance.ceReload = (newStyles) => {
1036 if (this._styles) {
1037 this._styles.forEach((s) => this._root.removeChild(s));
1038 this._styles.length = 0;
1039 }
1040 this._applyStyles(newStyles);
1041 this._instance = null;
1042 this._update();
1043 };
1044 }
1045 const dispatch = (event, args) => {
1046 this.dispatchEvent(
1047 new CustomEvent(
1048 event,
1049 shared.isPlainObject(args[0]) ? shared.extend({ detail: args }, args[0]) : { detail: args }
1050 )
1051 );
1052 };
1053 instance.emit = (event, ...args) => {
1054 dispatch(event, args);
1055 if (shared.hyphenate(event) !== event) {
1056 dispatch(shared.hyphenate(event), args);
1057 }
1058 };
1059 this._setParent();
1060 };
1061 }
1062 return vnode;
1063 }
1064 _applyStyles(styles, owner) {
1065 if (!styles) return;
1066 if (owner) {
1067 if (owner === this._def || this._styleChildren.has(owner)) {
1068 return;
1069 }
1070 this._styleChildren.add(owner);
1071 }
1072 const nonce = this._nonce;
1073 for (let i = styles.length - 1; i >= 0; i--) {
1074 const s = document.createElement("style");
1075 if (nonce) s.setAttribute("nonce", nonce);
1076 s.textContent = styles[i];
1077 this.shadowRoot.prepend(s);
1078 {
1079 if (owner) {
1080 if (owner.__hmrId) {
1081 if (!this._childStyles) this._childStyles = /* @__PURE__ */ new Map();
1082 let entry = this._childStyles.get(owner.__hmrId);
1083 if (!entry) {
1084 this._childStyles.set(owner.__hmrId, entry = []);
1085 }
1086 entry.push(s);
1087 }
1088 } else {
1089 (this._styles || (this._styles = [])).push(s);
1090 }
1091 }
1092 }
1093 }
1094 /**
1095 * Only called when shadowRoot is false
1096 */
1097 _parseSlots() {
1098 const slots = this._slots = {};
1099 let n;
1100 while (n = this.firstChild) {
1101 const slotName = n.nodeType === 1 && n.getAttribute("slot") || "default";
1102 (slots[slotName] || (slots[slotName] = [])).push(n);
1103 this.removeChild(n);
1104 }
1105 }
1106 /**
1107 * Only called when shadowRoot is false
1108 */
1109 _renderSlots() {
1110 const outlets = (this._teleportTarget || this).querySelectorAll("slot");
1111 const scopeId = this._instance.type.__scopeId;
1112 for (let i = 0; i < outlets.length; i++) {
1113 const o = outlets[i];
1114 const slotName = o.getAttribute("name") || "default";
1115 const content = this._slots[slotName];
1116 const parent = o.parentNode;
1117 if (content) {
1118 for (const n of content) {
1119 if (scopeId && n.nodeType === 1) {
1120 const id = scopeId + "-s";
1121 const walker = document.createTreeWalker(n, 1);
1122 n.setAttribute(id, "");
1123 let child;
1124 while (child = walker.nextNode()) {
1125 child.setAttribute(id, "");
1126 }
1127 }
1128 parent.insertBefore(n, o);
1129 }
1130 } else {
1131 while (o.firstChild) parent.insertBefore(o.firstChild, o);
1132 }
1133 parent.removeChild(o);
1134 }
1135 }
1136 /**
1137 * @internal
1138 */
1139 _injectChildStyle(comp) {
1140 this._applyStyles(comp.styles, comp);
1141 }
1142 /**
1143 * @internal
1144 */
1145 _removeChildStyle(comp) {
1146 {
1147 this._styleChildren.delete(comp);
1148 if (this._childStyles && comp.__hmrId) {
1149 const oldStyles = this._childStyles.get(comp.__hmrId);
1150 if (oldStyles) {
1151 oldStyles.forEach((s) => this._root.removeChild(s));
1152 oldStyles.length = 0;
1153 }
1154 }
1155 }
1156 }
1157}
1158function useHost(caller) {
1159 const instance = runtimeCore.getCurrentInstance();
1160 const el = instance && instance.ce;
1161 if (el) {
1162 return el;
1163 } else {
1164 if (!instance) {
1165 runtimeCore.warn(
1166 `${caller || "useHost"} called without an active component instance.`
1167 );
1168 } else {
1169 runtimeCore.warn(
1170 `${caller || "useHost"} can only be used in components defined via defineCustomElement.`
1171 );
1172 }
1173 }
1174 return null;
1175}
1176function useShadowRoot() {
1177 const el = useHost("useShadowRoot") ;
1178 return el && el.shadowRoot;
1179}
1180
1181function useCssModule(name = "$style") {
1182 {
1183 const instance = runtimeCore.getCurrentInstance();
1184 if (!instance) {
1185 runtimeCore.warn(`useCssModule must be called inside setup()`);
1186 return shared.EMPTY_OBJ;
1187 }
1188 const modules = instance.type.__cssModules;
1189 if (!modules) {
1190 runtimeCore.warn(`Current instance does not have CSS modules injected.`);
1191 return shared.EMPTY_OBJ;
1192 }
1193 const mod = modules[name];
1194 if (!mod) {
1195 runtimeCore.warn(`Current instance does not have CSS module named "${name}".`);
1196 return shared.EMPTY_OBJ;
1197 }
1198 return mod;
1199 }
1200}
1201
1202const positionMap = /* @__PURE__ */ new WeakMap();
1203const newPositionMap = /* @__PURE__ */ new WeakMap();
1204const moveCbKey = Symbol("_moveCb");
1205const enterCbKey = Symbol("_enterCb");
1206const decorate = (t) => {
1207 delete t.props.mode;
1208 return t;
1209};
1210const TransitionGroupImpl = /* @__PURE__ */ decorate({
1211 name: "TransitionGroup",
1212 props: /* @__PURE__ */ shared.extend({}, TransitionPropsValidators, {
1213 tag: String,
1214 moveClass: String
1215 }),
1216 setup(props, { slots }) {
1217 const instance = runtimeCore.getCurrentInstance();
1218 const state = runtimeCore.useTransitionState();
1219 let prevChildren;
1220 let children;
1221 runtimeCore.onUpdated(() => {
1222 if (!prevChildren.length) {
1223 return;
1224 }
1225 const moveClass = props.moveClass || `${props.name || "v"}-move`;
1226 if (!hasCSSTransform(
1227 prevChildren[0].el,
1228 instance.vnode.el,
1229 moveClass
1230 )) {
1231 return;
1232 }
1233 prevChildren.forEach(callPendingCbs);
1234 prevChildren.forEach(recordPosition);
1235 const movedChildren = prevChildren.filter(applyTranslation);
1236 forceReflow();
1237 movedChildren.forEach((c) => {
1238 const el = c.el;
1239 const style = el.style;
1240 addTransitionClass(el, moveClass);
1241 style.transform = style.webkitTransform = style.transitionDuration = "";
1242 const cb = el[moveCbKey] = (e) => {
1243 if (e && e.target !== el) {
1244 return;
1245 }
1246 if (!e || /transform$/.test(e.propertyName)) {
1247 el.removeEventListener("transitionend", cb);
1248 el[moveCbKey] = null;
1249 removeTransitionClass(el, moveClass);
1250 }
1251 };
1252 el.addEventListener("transitionend", cb);
1253 });
1254 });
1255 return () => {
1256 const rawProps = runtimeCore.toRaw(props);
1257 const cssTransitionProps = resolveTransitionProps(rawProps);
1258 let tag = rawProps.tag || runtimeCore.Fragment;
1259 prevChildren = [];
1260 if (children) {
1261 for (let i = 0; i < children.length; i++) {
1262 const child = children[i];
1263 if (child.el && child.el instanceof Element) {
1264 prevChildren.push(child);
1265 runtimeCore.setTransitionHooks(
1266 child,
1267 runtimeCore.resolveTransitionHooks(
1268 child,
1269 cssTransitionProps,
1270 state,
1271 instance
1272 )
1273 );
1274 positionMap.set(
1275 child,
1276 child.el.getBoundingClientRect()
1277 );
1278 }
1279 }
1280 }
1281 children = slots.default ? runtimeCore.getTransitionRawChildren(slots.default()) : [];
1282 for (let i = 0; i < children.length; i++) {
1283 const child = children[i];
1284 if (child.key != null) {
1285 runtimeCore.setTransitionHooks(
1286 child,
1287 runtimeCore.resolveTransitionHooks(child, cssTransitionProps, state, instance)
1288 );
1289 } else if (child.type !== runtimeCore.Text) {
1290 runtimeCore.warn(`<TransitionGroup> children must be keyed.`);
1291 }
1292 }
1293 return runtimeCore.createVNode(tag, null, children);
1294 };
1295 }
1296});
1297const TransitionGroup = TransitionGroupImpl;
1298function callPendingCbs(c) {
1299 const el = c.el;
1300 if (el[moveCbKey]) {
1301 el[moveCbKey]();
1302 }
1303 if (el[enterCbKey]) {
1304 el[enterCbKey]();
1305 }
1306}
1307function recordPosition(c) {
1308 newPositionMap.set(c, c.el.getBoundingClientRect());
1309}
1310function applyTranslation(c) {
1311 const oldPos = positionMap.get(c);
1312 const newPos = newPositionMap.get(c);
1313 const dx = oldPos.left - newPos.left;
1314 const dy = oldPos.top - newPos.top;
1315 if (dx || dy) {
1316 const s = c.el.style;
1317 s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
1318 s.transitionDuration = "0s";
1319 return c;
1320 }
1321}
1322function hasCSSTransform(el, root, moveClass) {
1323 const clone = el.cloneNode();
1324 const _vtc = el[vtcKey];
1325 if (_vtc) {
1326 _vtc.forEach((cls) => {
1327 cls.split(/\s+/).forEach((c) => c && clone.classList.remove(c));
1328 });
1329 }
1330 moveClass.split(/\s+/).forEach((c) => c && clone.classList.add(c));
1331 clone.style.display = "none";
1332 const container = root.nodeType === 1 ? root : root.parentNode;
1333 container.appendChild(clone);
1334 const { hasTransform } = getTransitionInfo(clone);
1335 container.removeChild(clone);
1336 return hasTransform;
1337}
1338
1339const getModelAssigner = (vnode) => {
1340 const fn = vnode.props["onUpdate:modelValue"] || false;
1341 return shared.isArray(fn) ? (value) => shared.invokeArrayFns(fn, value) : fn;
1342};
1343function onCompositionStart(e) {
1344 e.target.composing = true;
1345}
1346function onCompositionEnd(e) {
1347 const target = e.target;
1348 if (target.composing) {
1349 target.composing = false;
1350 target.dispatchEvent(new Event("input"));
1351 }
1352}
1353const assignKey = Symbol("_assign");
1354const vModelText = {
1355 created(el, { modifiers: { lazy, trim, number } }, vnode) {
1356 el[assignKey] = getModelAssigner(vnode);
1357 const castToNumber = number || vnode.props && vnode.props.type === "number";
1358 addEventListener(el, lazy ? "change" : "input", (e) => {
1359 if (e.target.composing) return;
1360 let domValue = el.value;
1361 if (trim) {
1362 domValue = domValue.trim();
1363 }
1364 if (castToNumber) {
1365 domValue = shared.looseToNumber(domValue);
1366 }
1367 el[assignKey](domValue);
1368 });
1369 if (trim) {
1370 addEventListener(el, "change", () => {
1371 el.value = el.value.trim();
1372 });
1373 }
1374 if (!lazy) {
1375 addEventListener(el, "compositionstart", onCompositionStart);
1376 addEventListener(el, "compositionend", onCompositionEnd);
1377 addEventListener(el, "change", onCompositionEnd);
1378 }
1379 },
1380 // set value on mounted so it's after min/max for type="range"
1381 mounted(el, { value }) {
1382 el.value = value == null ? "" : value;
1383 },
1384 beforeUpdate(el, { value, oldValue, modifiers: { lazy, trim, number } }, vnode) {
1385 el[assignKey] = getModelAssigner(vnode);
1386 if (el.composing) return;
1387 const elValue = (number || el.type === "number") && !/^0\d/.test(el.value) ? shared.looseToNumber(el.value) : el.value;
1388 const newValue = value == null ? "" : value;
1389 if (elValue === newValue) {
1390 return;
1391 }
1392 if (document.activeElement === el && el.type !== "range") {
1393 if (lazy && value === oldValue) {
1394 return;
1395 }
1396 if (trim && el.value.trim() === newValue) {
1397 return;
1398 }
1399 }
1400 el.value = newValue;
1401 }
1402};
1403const vModelCheckbox = {
1404 // #4096 array checkboxes need to be deep traversed
1405 deep: true,
1406 created(el, _, vnode) {
1407 el[assignKey] = getModelAssigner(vnode);
1408 addEventListener(el, "change", () => {
1409 const modelValue = el._modelValue;
1410 const elementValue = getValue(el);
1411 const checked = el.checked;
1412 const assign = el[assignKey];
1413 if (shared.isArray(modelValue)) {
1414 const index = shared.looseIndexOf(modelValue, elementValue);
1415 const found = index !== -1;
1416 if (checked && !found) {
1417 assign(modelValue.concat(elementValue));
1418 } else if (!checked && found) {
1419 const filtered = [...modelValue];
1420 filtered.splice(index, 1);
1421 assign(filtered);
1422 }
1423 } else if (shared.isSet(modelValue)) {
1424 const cloned = new Set(modelValue);
1425 if (checked) {
1426 cloned.add(elementValue);
1427 } else {
1428 cloned.delete(elementValue);
1429 }
1430 assign(cloned);
1431 } else {
1432 assign(getCheckboxValue(el, checked));
1433 }
1434 });
1435 },
1436 // set initial checked on mount to wait for true-value/false-value
1437 mounted: setChecked,
1438 beforeUpdate(el, binding, vnode) {
1439 el[assignKey] = getModelAssigner(vnode);
1440 setChecked(el, binding, vnode);
1441 }
1442};
1443function setChecked(el, { value, oldValue }, vnode) {
1444 el._modelValue = value;
1445 let checked;
1446 if (shared.isArray(value)) {
1447 checked = shared.looseIndexOf(value, vnode.props.value) > -1;
1448 } else if (shared.isSet(value)) {
1449 checked = value.has(vnode.props.value);
1450 } else {
1451 if (value === oldValue) return;
1452 checked = shared.looseEqual(value, getCheckboxValue(el, true));
1453 }
1454 if (el.checked !== checked) {
1455 el.checked = checked;
1456 }
1457}
1458const vModelRadio = {
1459 created(el, { value }, vnode) {
1460 el.checked = shared.looseEqual(value, vnode.props.value);
1461 el[assignKey] = getModelAssigner(vnode);
1462 addEventListener(el, "change", () => {
1463 el[assignKey](getValue(el));
1464 });
1465 },
1466 beforeUpdate(el, { value, oldValue }, vnode) {
1467 el[assignKey] = getModelAssigner(vnode);
1468 if (value !== oldValue) {
1469 el.checked = shared.looseEqual(value, vnode.props.value);
1470 }
1471 }
1472};
1473const vModelSelect = {
1474 // <select multiple> value need to be deep traversed
1475 deep: true,
1476 created(el, { value, modifiers: { number } }, vnode) {
1477 const isSetModel = shared.isSet(value);
1478 addEventListener(el, "change", () => {
1479 const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map(
1480 (o) => number ? shared.looseToNumber(getValue(o)) : getValue(o)
1481 );
1482 el[assignKey](
1483 el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]
1484 );
1485 el._assigning = true;
1486 runtimeCore.nextTick(() => {
1487 el._assigning = false;
1488 });
1489 });
1490 el[assignKey] = getModelAssigner(vnode);
1491 },
1492 // set value in mounted & updated because <select> relies on its children
1493 // <option>s.
1494 mounted(el, { value }) {
1495 setSelected(el, value);
1496 },
1497 beforeUpdate(el, _binding, vnode) {
1498 el[assignKey] = getModelAssigner(vnode);
1499 },
1500 updated(el, { value }) {
1501 if (!el._assigning) {
1502 setSelected(el, value);
1503 }
1504 }
1505};
1506function setSelected(el, value) {
1507 const isMultiple = el.multiple;
1508 const isArrayValue = shared.isArray(value);
1509 if (isMultiple && !isArrayValue && !shared.isSet(value)) {
1510 runtimeCore.warn(
1511 `<select multiple v-model> expects an Array or Set value for its binding, but got ${Object.prototype.toString.call(value).slice(8, -1)}.`
1512 );
1513 return;
1514 }
1515 for (let i = 0, l = el.options.length; i < l; i++) {
1516 const option = el.options[i];
1517 const optionValue = getValue(option);
1518 if (isMultiple) {
1519 if (isArrayValue) {
1520 const optionType = typeof optionValue;
1521 if (optionType === "string" || optionType === "number") {
1522 option.selected = value.some((v) => String(v) === String(optionValue));
1523 } else {
1524 option.selected = shared.looseIndexOf(value, optionValue) > -1;
1525 }
1526 } else {
1527 option.selected = value.has(optionValue);
1528 }
1529 } else if (shared.looseEqual(getValue(option), value)) {
1530 if (el.selectedIndex !== i) el.selectedIndex = i;
1531 return;
1532 }
1533 }
1534 if (!isMultiple && el.selectedIndex !== -1) {
1535 el.selectedIndex = -1;
1536 }
1537}
1538function getValue(el) {
1539 return "_value" in el ? el._value : el.value;
1540}
1541function getCheckboxValue(el, checked) {
1542 const key = checked ? "_trueValue" : "_falseValue";
1543 return key in el ? el[key] : checked;
1544}
1545const vModelDynamic = {
1546 created(el, binding, vnode) {
1547 callModelHook(el, binding, vnode, null, "created");
1548 },
1549 mounted(el, binding, vnode) {
1550 callModelHook(el, binding, vnode, null, "mounted");
1551 },
1552 beforeUpdate(el, binding, vnode, prevVNode) {
1553 callModelHook(el, binding, vnode, prevVNode, "beforeUpdate");
1554 },
1555 updated(el, binding, vnode, prevVNode) {
1556 callModelHook(el, binding, vnode, prevVNode, "updated");
1557 }
1558};
1559function resolveDynamicModel(tagName, type) {
1560 switch (tagName) {
1561 case "SELECT":
1562 return vModelSelect;
1563 case "TEXTAREA":
1564 return vModelText;
1565 default:
1566 switch (type) {
1567 case "checkbox":
1568 return vModelCheckbox;
1569 case "radio":
1570 return vModelRadio;
1571 default:
1572 return vModelText;
1573 }
1574 }
1575}
1576function callModelHook(el, binding, vnode, prevVNode, hook) {
1577 const modelToUse = resolveDynamicModel(
1578 el.tagName,
1579 vnode.props && vnode.props.type
1580 );
1581 const fn = modelToUse[hook];
1582 fn && fn(el, binding, vnode, prevVNode);
1583}
1584function initVModelForSSR() {
1585 vModelText.getSSRProps = ({ value }) => ({ value });
1586 vModelRadio.getSSRProps = ({ value }, vnode) => {
1587 if (vnode.props && shared.looseEqual(vnode.props.value, value)) {
1588 return { checked: true };
1589 }
1590 };
1591 vModelCheckbox.getSSRProps = ({ value }, vnode) => {
1592 if (shared.isArray(value)) {
1593 if (vnode.props && shared.looseIndexOf(value, vnode.props.value) > -1) {
1594 return { checked: true };
1595 }
1596 } else if (shared.isSet(value)) {
1597 if (vnode.props && value.has(vnode.props.value)) {
1598 return { checked: true };
1599 }
1600 } else if (value) {
1601 return { checked: true };
1602 }
1603 };
1604 vModelDynamic.getSSRProps = (binding, vnode) => {
1605 if (typeof vnode.type !== "string") {
1606 return;
1607 }
1608 const modelToUse = resolveDynamicModel(
1609 // resolveDynamicModel expects an uppercase tag name, but vnode.type is lowercase
1610 vnode.type.toUpperCase(),
1611 vnode.props && vnode.props.type
1612 );
1613 if (modelToUse.getSSRProps) {
1614 return modelToUse.getSSRProps(binding, vnode);
1615 }
1616 };
1617}
1618
1619const systemModifiers = ["ctrl", "shift", "alt", "meta"];
1620const modifierGuards = {
1621 stop: (e) => e.stopPropagation(),
1622 prevent: (e) => e.preventDefault(),
1623 self: (e) => e.target !== e.currentTarget,
1624 ctrl: (e) => !e.ctrlKey,
1625 shift: (e) => !e.shiftKey,
1626 alt: (e) => !e.altKey,
1627 meta: (e) => !e.metaKey,
1628 left: (e) => "button" in e && e.button !== 0,
1629 middle: (e) => "button" in e && e.button !== 1,
1630 right: (e) => "button" in e && e.button !== 2,
1631 exact: (e, modifiers) => systemModifiers.some((m) => e[`${m}Key`] && !modifiers.includes(m))
1632};
1633const withModifiers = (fn, modifiers) => {
1634 const cache = fn._withMods || (fn._withMods = {});
1635 const cacheKey = modifiers.join(".");
1636 return cache[cacheKey] || (cache[cacheKey] = (event, ...args) => {
1637 for (let i = 0; i < modifiers.length; i++) {
1638 const guard = modifierGuards[modifiers[i]];
1639 if (guard && guard(event, modifiers)) return;
1640 }
1641 return fn(event, ...args);
1642 });
1643};
1644const keyNames = {
1645 esc: "escape",
1646 space: " ",
1647 up: "arrow-up",
1648 left: "arrow-left",
1649 right: "arrow-right",
1650 down: "arrow-down",
1651 delete: "backspace"
1652};
1653const withKeys = (fn, modifiers) => {
1654 const cache = fn._withKeys || (fn._withKeys = {});
1655 const cacheKey = modifiers.join(".");
1656 return cache[cacheKey] || (cache[cacheKey] = (event) => {
1657 if (!("key" in event)) {
1658 return;
1659 }
1660 const eventKey = shared.hyphenate(event.key);
1661 if (modifiers.some(
1662 (k) => k === eventKey || keyNames[k] === eventKey
1663 )) {
1664 return fn(event);
1665 }
1666 });
1667};
1668
1669const rendererOptions = /* @__PURE__ */ shared.extend({ patchProp }, nodeOps);
1670let renderer;
1671let enabledHydration = false;
1672function ensureRenderer() {
1673 return renderer || (renderer = runtimeCore.createRenderer(rendererOptions));
1674}
1675function ensureHydrationRenderer() {
1676 renderer = enabledHydration ? renderer : runtimeCore.createHydrationRenderer(rendererOptions);
1677 enabledHydration = true;
1678 return renderer;
1679}
1680const render = (...args) => {
1681 ensureRenderer().render(...args);
1682};
1683const hydrate = (...args) => {
1684 ensureHydrationRenderer().hydrate(...args);
1685};
1686const createApp = (...args) => {
1687 const app = ensureRenderer().createApp(...args);
1688 {
1689 injectNativeTagCheck(app);
1690 injectCompilerOptionsCheck(app);
1691 }
1692 const { mount } = app;
1693 app.mount = (containerOrSelector) => {
1694 const container = normalizeContainer(containerOrSelector);
1695 if (!container) return;
1696 const component = app._component;
1697 if (!shared.isFunction(component) && !component.render && !component.template) {
1698 component.template = container.innerHTML;
1699 }
1700 if (container.nodeType === 1) {
1701 container.textContent = "";
1702 }
1703 const proxy = mount(container, false, resolveRootNamespace(container));
1704 if (container instanceof Element) {
1705 container.removeAttribute("v-cloak");
1706 container.setAttribute("data-v-app", "");
1707 }
1708 return proxy;
1709 };
1710 return app;
1711};
1712const createSSRApp = (...args) => {
1713 const app = ensureHydrationRenderer().createApp(...args);
1714 {
1715 injectNativeTagCheck(app);
1716 injectCompilerOptionsCheck(app);
1717 }
1718 const { mount } = app;
1719 app.mount = (containerOrSelector) => {
1720 const container = normalizeContainer(containerOrSelector);
1721 if (container) {
1722 return mount(container, true, resolveRootNamespace(container));
1723 }
1724 };
1725 return app;
1726};
1727function resolveRootNamespace(container) {
1728 if (container instanceof SVGElement) {
1729 return "svg";
1730 }
1731 if (typeof MathMLElement === "function" && container instanceof MathMLElement) {
1732 return "mathml";
1733 }
1734}
1735function injectNativeTagCheck(app) {
1736 Object.defineProperty(app.config, "isNativeTag", {
1737 value: (tag) => shared.isHTMLTag(tag) || shared.isSVGTag(tag) || shared.isMathMLTag(tag),
1738 writable: false
1739 });
1740}
1741function injectCompilerOptionsCheck(app) {
1742 if (runtimeCore.isRuntimeOnly()) {
1743 const isCustomElement = app.config.isCustomElement;
1744 Object.defineProperty(app.config, "isCustomElement", {
1745 get() {
1746 return isCustomElement;
1747 },
1748 set() {
1749 runtimeCore.warn(
1750 `The \`isCustomElement\` config option is deprecated. Use \`compilerOptions.isCustomElement\` instead.`
1751 );
1752 }
1753 });
1754 const compilerOptions = app.config.compilerOptions;
1755 const msg = `The \`compilerOptions\` config option is only respected when using a build of Vue.js that includes the runtime compiler (aka "full build"). Since you are using the runtime-only build, \`compilerOptions\` must be passed to \`@vue/compiler-dom\` in the build setup instead.
1756- For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.
1757- For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader
1758- For vite: pass it via @vitejs/plugin-vue options. See https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue#example-for-passing-options-to-vuecompiler-sfc`;
1759 Object.defineProperty(app.config, "compilerOptions", {
1760 get() {
1761 runtimeCore.warn(msg);
1762 return compilerOptions;
1763 },
1764 set() {
1765 runtimeCore.warn(msg);
1766 }
1767 });
1768 }
1769}
1770function normalizeContainer(container) {
1771 if (shared.isString(container)) {
1772 const res = document.querySelector(container);
1773 if (!res) {
1774 runtimeCore.warn(
1775 `Failed to mount app: mount target selector "${container}" returned null.`
1776 );
1777 }
1778 return res;
1779 }
1780 if (window.ShadowRoot && container instanceof window.ShadowRoot && container.mode === "closed") {
1781 runtimeCore.warn(
1782 `mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`
1783 );
1784 }
1785 return container;
1786}
1787let ssrDirectiveInitialized = false;
1788const initDirectivesForSSR = () => {
1789 if (!ssrDirectiveInitialized) {
1790 ssrDirectiveInitialized = true;
1791 initVModelForSSR();
1792 initVShowForSSR();
1793 }
1794} ;
1795
1796exports.Transition = Transition;
1797exports.TransitionGroup = TransitionGroup;
1798exports.VueElement = VueElement;
1799exports.createApp = createApp;
1800exports.createSSRApp = createSSRApp;
1801exports.defineCustomElement = defineCustomElement;
1802exports.defineSSRCustomElement = defineSSRCustomElement;
1803exports.hydrate = hydrate;
1804exports.initDirectivesForSSR = initDirectivesForSSR;
1805exports.render = render;
1806exports.useCssModule = useCssModule;
1807exports.useCssVars = useCssVars;
1808exports.useHost = useHost;
1809exports.useShadowRoot = useShadowRoot;
1810exports.vModelCheckbox = vModelCheckbox;
1811exports.vModelDynamic = vModelDynamic;
1812exports.vModelRadio = vModelRadio;
1813exports.vModelSelect = vModelSelect;
1814exports.vModelText = vModelText;
1815exports.vShow = vShow;
1816exports.withKeys = withKeys;
1817exports.withModifiers = withModifiers;
1818Object.keys(runtimeCore).forEach(function (k) {
1819 if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = runtimeCore[k];
1820});
Note: See TracBrowser for help on using the repository browser.