@aevantec/litevue 0.6.1 → 0.6.3
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.
- package/dist/litevue-devtools.iife.js +1 -1
- package/dist/litevue-devtools.mjs +1 -1
- package/dist/litevue-devtools.umd.js +1 -1
- package/dist/litevue-plugins.dev.iife.js +67 -125
- package/dist/litevue-plugins.dev.mjs +67 -124
- package/dist/litevue-plugins.iife.js +1 -1
- package/dist/litevue-plugins.mjs +1 -1
- package/dist/litevue-plugins.umd.js +1 -1
- package/dist/litevue.dev.iife.js +122 -159
- package/dist/litevue.dev.mjs +122 -158
- package/dist/litevue.iife.js +1 -1
- package/dist/litevue.mjs +1 -1
- package/dist/litevue.umd.js +1 -1
- package/dist/plugins/collapse.iife.js +1 -1
- package/dist/plugins/collapse.mjs +1 -1
- package/dist/plugins/collapse.umd.js +1 -1
- package/dist/plugins/focus.iife.js +1 -1
- package/dist/plugins/focus.mjs +1 -1
- package/dist/plugins/focus.umd.js +1 -1
- package/dist/plugins/intersect.iife.js +1 -1
- package/dist/plugins/intersect.umd.js +1 -1
- package/dist/plugins/mask.iife.js +1 -1
- package/dist/plugins/mask.mjs +1 -1
- package/dist/plugins/mask.umd.js +1 -1
- package/dist/plugins/media.dev.iife.js +5 -39
- package/dist/plugins/media.dev.mjs +5 -38
- package/dist/plugins/media.iife.js +1 -1
- package/dist/plugins/media.mjs +1 -1
- package/dist/plugins/media.umd.js +1 -1
- package/dist/plugins/morph.dev.iife.js +41 -61
- package/dist/plugins/morph.dev.mjs +41 -60
- package/dist/plugins/morph.iife.js +1 -1
- package/dist/plugins/morph.mjs +1 -1
- package/dist/plugins/morph.umd.js +1 -1
- package/dist/plugins/navigate.dev.iife.js +24 -26
- package/dist/plugins/navigate.dev.mjs +24 -25
- package/dist/plugins/navigate.iife.js +1 -1
- package/dist/plugins/navigate.mjs +1 -1
- package/dist/plugins/navigate.umd.js +1 -1
- package/dist/plugins/persist.dev.iife.js +2 -10
- package/dist/plugins/persist.dev.mjs +2 -9
- package/dist/plugins/persist.iife.js +1 -1
- package/dist/plugins/persist.mjs +1 -1
- package/dist/plugins/persist.umd.js +1 -1
- package/dist/plugins/popover.iife.js +1 -1
- package/dist/plugins/popover.mjs +1 -1
- package/dist/plugins/popover.umd.js +1 -1
- package/dist/plugins/resize.iife.js +1 -1
- package/dist/plugins/resize.umd.js +1 -1
- package/dist/plugins/transition.iife.js +1 -1
- package/dist/plugins/transition.mjs +1 -1
- package/dist/plugins/transition.umd.js +1 -1
- package/dist/types/app.d.mts +5 -6
- package/dist/types/app.d.ts +5 -6
- package/dist/types/block.d.mts +0 -4
- package/dist/types/block.d.ts +0 -4
- package/dist/types/context.d.mts +1 -6
- package/dist/types/context.d.ts +1 -6
- package/dist/types/devtools-panel/chrome.d.mts +5 -7
- package/dist/types/devtools-panel/chrome.d.ts +5 -7
- package/dist/types/devtools-panel/menu.d.mts +10 -0
- package/dist/types/devtools-panel/menu.d.ts +10 -0
- package/dist/types/devtools-panel/plugins.d.mts +0 -4
- package/dist/types/devtools-panel/plugins.d.ts +0 -4
- package/dist/types/devtools-panel/styles.d.mts +3 -15
- package/dist/types/devtools-panel/styles.d.ts +3 -15
- package/dist/types/devtools-panel/values.d.mts +1 -20
- package/dist/types/devtools-panel/values.d.ts +1 -20
- package/dist/types/devtools.d.mts +0 -7
- package/dist/types/devtools.d.ts +0 -7
- package/dist/types/directives/on.d.mts +0 -1
- package/dist/types/directives/on.d.ts +0 -1
- package/dist/types/directives/show.d.mts +1 -0
- package/dist/types/directives/show.d.ts +1 -0
- package/dist/types/errors.d.mts +1 -8
- package/dist/types/errors.d.ts +1 -8
- package/dist/types/eval.d.mts +0 -3
- package/dist/types/eval.d.ts +0 -3
- package/dist/types/lazy.d.mts +0 -10
- package/dist/types/lazy.d.ts +0 -10
- package/dist/types/magics.d.mts +0 -9
- package/dist/types/magics.d.ts +0 -9
- package/dist/types/ownership.d.mts +0 -19
- package/dist/types/ownership.d.ts +0 -19
- package/dist/types/plugins/media/index.d.mts +0 -5
- package/dist/types/plugins/media/index.d.ts +0 -5
- package/dist/types/plugins/morph/index.d.mts +0 -8
- package/dist/types/plugins/morph/index.d.ts +0 -8
- package/dist/types/scheduler.d.mts +0 -5
- package/dist/types/scheduler.d.ts +0 -5
- package/dist/types/store.d.mts +5 -1
- package/dist/types/store.d.ts +5 -1
- package/dist/types/utils.d.mts +0 -5
- package/dist/types/utils.d.ts +0 -5
- package/dist/types/warn.d.mts +0 -12
- package/dist/types/warn.d.ts +0 -12
- package/package.json +3 -3
package/dist/litevue.dev.iife.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
var LiteVue = (function(exports) {
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
2
|
// node_modules/.pnpm/@vue+shared@3.4.38/node_modules/@vue/shared/dist/shared.esm-bundler.js
|
|
4
3
|
/**
|
|
5
4
|
* @vue/shared v3.4.38
|
|
@@ -33,7 +32,6 @@ var LiteVue = (function(exports) {
|
|
|
33
32
|
var toRawType = (value) => {
|
|
34
33
|
return toTypeString(value).slice(8, -1);
|
|
35
34
|
};
|
|
36
|
-
var isPlainObject = (val) => toTypeString(val) === "[object Object]";
|
|
37
35
|
var isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
|
|
38
36
|
var cacheStringFunction = (fn) => {
|
|
39
37
|
const cache = /* @__PURE__ */ Object.create(null);
|
|
@@ -615,7 +613,13 @@ getter: `, this.getter);
|
|
|
615
613
|
flush: /* @__PURE__ */ new Set()
|
|
616
614
|
};
|
|
617
615
|
var emit = (event, ...args) => {
|
|
618
|
-
listeners[event].forEach((fn) =>
|
|
616
|
+
listeners[event].forEach((fn) => {
|
|
617
|
+
try {
|
|
618
|
+
fn(...args);
|
|
619
|
+
} catch (e) {
|
|
620
|
+
console.error(`[litevue] a devtools "${event}" listener threw:`, e);
|
|
621
|
+
}
|
|
622
|
+
});
|
|
619
623
|
};
|
|
620
624
|
var registerScope = (el, scope, exp, name) => {
|
|
621
625
|
if (isDisabled()) return NOOP;
|
|
@@ -639,7 +643,6 @@ getter: `, this.getter);
|
|
|
639
643
|
var registerComponent = (name) => {
|
|
640
644
|
if (!isDisabled()) componentNames.add(name);
|
|
641
645
|
};
|
|
642
|
-
/** Registers a plugin and returns a deregister, as registerScope does. */
|
|
643
646
|
var registerPlugin = (info) => {
|
|
644
647
|
if (isDisabled()) return;
|
|
645
648
|
pluginList.push(info);
|
|
@@ -649,7 +652,6 @@ getter: `, this.getter);
|
|
|
649
652
|
if (i > -1) pluginList.splice(i, 1);
|
|
650
653
|
};
|
|
651
654
|
};
|
|
652
|
-
/** True when something is listening, so app.use() can skip the diff. */
|
|
653
655
|
var pluginsWatched = () => !isDisabled();
|
|
654
656
|
var emitFlush = () => {
|
|
655
657
|
if (listeners.flush.size && !isDisabled()) emit("flush");
|
|
@@ -669,7 +671,7 @@ getter: `, this.getter);
|
|
|
669
671
|
while (el) {
|
|
670
672
|
const scope = scopes.get(el);
|
|
671
673
|
if (scope) return scope;
|
|
672
|
-
el = el.parentElement;
|
|
674
|
+
el = el.__marker?.parentElement || el.parentElement;
|
|
673
675
|
}
|
|
674
676
|
},
|
|
675
677
|
on(event, fn) {
|
|
@@ -699,7 +701,6 @@ getter: `, this.getter);
|
|
|
699
701
|
};
|
|
700
702
|
if (typeof window !== "undefined" && !isDisabled()) window.__LITE_VUE__ = devtools;
|
|
701
703
|
// src/errors.ts
|
|
702
|
-
/** Levenshtein, bounded — only used to rank candidate names in DEV. */
|
|
703
704
|
var distance = (a, b) => {
|
|
704
705
|
const m = a.length;
|
|
705
706
|
const n = b.length;
|
|
@@ -713,7 +714,6 @@ getter: `, this.getter);
|
|
|
713
714
|
}
|
|
714
715
|
return prev[n];
|
|
715
716
|
};
|
|
716
|
-
/** Every name in scope, up the prototype chain that nested `v-scope`s inherit. */
|
|
717
717
|
var scopeNames = (scope) => {
|
|
718
718
|
const names = /* @__PURE__ */ new Set();
|
|
719
719
|
let cur = scope;
|
|
@@ -723,7 +723,6 @@ getter: `, this.getter);
|
|
|
723
723
|
}
|
|
724
724
|
return [...names];
|
|
725
725
|
};
|
|
726
|
-
/** `count is not defined` → the closest name actually in scope. */
|
|
727
726
|
var suggestName = (err, scope) => {
|
|
728
727
|
if (!scope || !(err instanceof ReferenceError)) return;
|
|
729
728
|
const missing = /^(\w+) is not defined$/.exec(err.message)?.[1];
|
|
@@ -744,14 +743,12 @@ getter: `, this.getter);
|
|
|
744
743
|
suggestion: best
|
|
745
744
|
} : { missing };
|
|
746
745
|
};
|
|
747
|
-
/** A short, recognisable rendering of the element — not its whole subtree. */
|
|
748
746
|
var describeEl = (el) => {
|
|
749
747
|
if (!el) return;
|
|
750
748
|
if (!(el instanceof Element)) return el.nodeType === 3 ? `text node "${el.nodeValue?.trim().slice(0, 40)}"` : void 0;
|
|
751
749
|
return `<${el.tagName.toLowerCase()}${el.id ? `#${el.id}` : ""}${el.classList.length ? `.${[...el.classList].join(".")}` : ""}>`;
|
|
752
750
|
};
|
|
753
751
|
var handlers = [];
|
|
754
|
-
/** Registered by `app.onError()`. Shared across apps, like the store registry. */
|
|
755
752
|
var addErrorHandler = (fn) => {
|
|
756
753
|
handlers.push(fn);
|
|
757
754
|
return () => {
|
|
@@ -788,17 +785,7 @@ getter: `, this.getter);
|
|
|
788
785
|
if (info.el) console.error(info.el);
|
|
789
786
|
};
|
|
790
787
|
// src/scheduler.ts
|
|
791
|
-
/**
|
|
792
|
-
* Effects this library has stopped.
|
|
793
|
-
*
|
|
794
|
-
* The scheduler must know whether a queued runner is still live, and
|
|
795
|
-
* @vue/reactivity offers no supported way to ask: 3.4's `ReactiveEffect.active`
|
|
796
|
-
* became an undeclared `flags` bitfield in 3.5. Since every stop here goes
|
|
797
|
-
* through `stopEffect`, tracking them ourselves is version-proof. Weak, so a
|
|
798
|
-
* stopped effect stays collectable.
|
|
799
|
-
*/
|
|
800
788
|
var stopped = /* @__PURE__ */ new WeakSet();
|
|
801
|
-
/** Stops an effect and remembers that it is stopped. Use instead of `stop`. */
|
|
802
789
|
var stopEffect = (runner) => {
|
|
803
790
|
stopped.add(runner);
|
|
804
791
|
if (runner.effect) stop(runner);
|
|
@@ -809,10 +796,6 @@ getter: `, this.getter);
|
|
|
809
796
|
var p = Promise.resolve();
|
|
810
797
|
var MAX_RUNS = 100;
|
|
811
798
|
var nextTick = (fn) => p.then(fn);
|
|
812
|
-
/**
|
|
813
|
-
* Stamps a job with its creation order, which the flush runs in. An effect
|
|
814
|
-
* stamped as it is created sorts before the children its first run creates.
|
|
815
|
-
*/
|
|
816
799
|
var stampJob = (job) => (job.i = uid$1++, job);
|
|
817
800
|
var queueJob = (job) => {
|
|
818
801
|
job.i ?? stampJob(job);
|
|
@@ -844,19 +827,10 @@ getter: `, this.getter);
|
|
|
844
827
|
};
|
|
845
828
|
// src/magics.ts
|
|
846
829
|
var uid = 0;
|
|
847
|
-
/**
|
|
848
|
-
* $id('name') — unique ids for accessibility attributes. Stable within a scope
|
|
849
|
-
* so label/input pairs match, unique across scopes.
|
|
850
|
-
*/
|
|
851
830
|
var createId = () => {
|
|
852
831
|
const memo = Object.create(null);
|
|
853
832
|
return (name = "id") => memo[name] || (memo[name] = `${name}-${++uid}`);
|
|
854
833
|
};
|
|
855
|
-
/**
|
|
856
|
-
* $watch(source, callback, { immediate }) — watches a dot-path string or getter
|
|
857
|
-
* and calls back with (value, oldValue). Returns a stop function; it also stops
|
|
858
|
-
* when the owning scope unmounts.
|
|
859
|
-
*/
|
|
860
834
|
var createWatch = (ctx) => (source, cb, options) => {
|
|
861
835
|
const getter = typeof source === "function" ? source : () => source.split(".").reduce((o, k) => o == null ? o : o[k], ctx.scope);
|
|
862
836
|
let oldValue;
|
|
@@ -871,6 +845,7 @@ getter: `, this.getter);
|
|
|
871
845
|
cb(value, previous);
|
|
872
846
|
} finally {
|
|
873
847
|
resetTracking();
|
|
848
|
+
oldValue = getter();
|
|
874
849
|
}
|
|
875
850
|
}
|
|
876
851
|
init = true;
|
|
@@ -891,15 +866,21 @@ getter: `, this.getter);
|
|
|
891
866
|
let value = get();
|
|
892
867
|
if (arg) {
|
|
893
868
|
if (modifiers?.camel) arg = camelize(arg);
|
|
894
|
-
|
|
869
|
+
patch(el, arg, value, prevValue);
|
|
895
870
|
} else {
|
|
896
|
-
|
|
871
|
+
const prev = Object(prevValue);
|
|
872
|
+
for (const key in value) (key in prev ? patch : setProp)(el, key, value[key], prev[key]);
|
|
897
873
|
for (const key in prevValue) if (!value || !(key in value)) setProp(el, key, null, prevValue[key]);
|
|
898
874
|
}
|
|
899
|
-
prevValue =
|
|
875
|
+
prevValue = snapshot(value);
|
|
876
|
+
if (!arg && prevValue?.style) prevValue.style = snapshot(prevValue.style);
|
|
900
877
|
if (!arg) el.__bound = prevValue;
|
|
901
878
|
});
|
|
902
879
|
};
|
|
880
|
+
var snapshot = (value) => isObject(value) ? { ...toStyle(value) } : value;
|
|
881
|
+
var patch = (el, key, value, prevValue) => {
|
|
882
|
+
if (value !== prevValue || isObject(value) || key === "value") setProp(el, key, value, prevValue);
|
|
883
|
+
};
|
|
903
884
|
var setProp = (el, key, value, prevValue) => {
|
|
904
885
|
if (key === "class") el.setAttribute("class", normalizeClass(el._class ? [el._class, value] : value) || "");
|
|
905
886
|
else if (key === "style") {
|
|
@@ -914,7 +895,12 @@ getter: `, this.getter);
|
|
|
914
895
|
}
|
|
915
896
|
if (!style.cssText) el.removeAttribute("style");
|
|
916
897
|
} else if (!(el instanceof SVGElement) && key in el && !forceAttrRE.test(key) && !mediaSizeRE.test(el.localName + key)) {
|
|
917
|
-
|
|
898
|
+
try {
|
|
899
|
+
const type = typeof el[key];
|
|
900
|
+
el[key] = value == null && type == "string" ? "" : value === "" && type == "boolean" || value;
|
|
901
|
+
} catch (e) {
|
|
902
|
+
if (value != null) throw e;
|
|
903
|
+
}
|
|
918
904
|
if (value == null) el.removeAttribute(key);
|
|
919
905
|
if (key === "value") el._value = value;
|
|
920
906
|
} else if (key === "true-value") el._trueValue = value;
|
|
@@ -934,22 +920,10 @@ getter: `, this.getter);
|
|
|
934
920
|
else style[name] = val;
|
|
935
921
|
};
|
|
936
922
|
// src/warn.ts
|
|
937
|
-
/**
|
|
938
|
-
* Development warnings.
|
|
939
|
-
*
|
|
940
|
-
* Every call site is guarded by `import.meta.env.DEV`; the production build
|
|
941
|
-
* replaces that constant and terser drops the branch, so neither these
|
|
942
|
-
* functions nor their strings ship. Messages are therefore free to be wordy —
|
|
943
|
-
* say what to do instead.
|
|
944
|
-
*/
|
|
945
923
|
var seen = /* @__PURE__ */ new Set();
|
|
946
924
|
var warn = (msg) => {
|
|
947
925
|
console.warn(`[litevue] ${msg}`);
|
|
948
926
|
};
|
|
949
|
-
/**
|
|
950
|
-
* Warns once per `key`. Most callers are effects, which re-run on every
|
|
951
|
-
* relevant change — one mistake would otherwise print on every keystroke.
|
|
952
|
-
*/
|
|
953
927
|
var warnOnce = (key, msg) => {
|
|
954
928
|
if (seen.has(key)) return;
|
|
955
929
|
seen.add(key);
|
|
@@ -998,10 +972,6 @@ getter: `, this.getter);
|
|
|
998
972
|
}
|
|
999
973
|
};
|
|
1000
974
|
// src/directives/on.ts
|
|
1001
|
-
/**
|
|
1002
|
-
* Can `exp` stand as a single expression, or is it a statement list?
|
|
1003
|
-
* Memoised: it compiles a throwaway function, which a `v-for` pays per row.
|
|
1004
|
-
*/
|
|
1005
975
|
var expressionCache = Object.create(null);
|
|
1006
976
|
var cachedExpressions = 0;
|
|
1007
977
|
var isExpression = (exp) => {
|
|
@@ -1055,7 +1025,9 @@ getter: `, this.getter);
|
|
|
1055
1025
|
return;
|
|
1056
1026
|
}
|
|
1057
1027
|
const a = /\bawait\b/.test(exp) ? "async " : "";
|
|
1058
|
-
|
|
1028
|
+
const body = exp.replace(/;\s*$/, "");
|
|
1029
|
+
let handler = simplePathRE.test(exp) || fnExpRE.test(exp) ? get(`(e => (${body})(e))`) : isExpression(body) ? get(`(${a}$event => (${body}))`) : get(`(${a}$event => { ${exp} })`);
|
|
1030
|
+
if (!handler) return;
|
|
1059
1031
|
if (arg === "vue:mounted" || arg === "vue:unmounted") console.warn(`@${arg} is deprecated in LiteVue - use @${arg.slice(4)} instead.`);
|
|
1060
1032
|
if (arg === "mounted" || arg === "vue:mounted") {
|
|
1061
1033
|
let live = true;
|
|
@@ -1105,7 +1077,7 @@ getter: `, this.getter);
|
|
|
1105
1077
|
warnOnce(`modifier:${arg}.${k}`, `@${arg}.${k}: .${k} is not a modifier LiteVue knows, so it is ignored.` + (ms ? ` Timings are written with a dash — .debounce-${ms[1]} or .throttle-${ms[1]}.` : ` Key names only filter keyboard events.`));
|
|
1106
1078
|
}
|
|
1107
1079
|
handler = (e) => {
|
|
1108
|
-
if (modifiers.outside && el.
|
|
1080
|
+
if (modifiers.outside && (e.composedPath().includes(el) || el._vsh || e.timeStamp < el._vts)) return;
|
|
1109
1081
|
if (keyFilter.length && ("key" in e || e.type.startsWith("key"))) {
|
|
1110
1082
|
const key = hyphenate(e.key || "");
|
|
1111
1083
|
if (!keyFilter.some((k) => k === key || keyAliases[k] === key)) return;
|
|
@@ -1122,6 +1094,7 @@ getter: `, this.getter);
|
|
|
1122
1094
|
}
|
|
1123
1095
|
const target = modifiers?.window ? window : modifiers?.document || modifiers?.outside ? document : el;
|
|
1124
1096
|
const event = arg;
|
|
1097
|
+
if (modifiers?.outside) el._vts = performance.now();
|
|
1125
1098
|
target.addEventListener(event, handler, {
|
|
1126
1099
|
...modifiers,
|
|
1127
1100
|
once: false
|
|
@@ -1135,12 +1108,15 @@ getter: `, this.getter);
|
|
|
1135
1108
|
var show = ({ el, get, effect }) => {
|
|
1136
1109
|
el._vod = el.style.display == "none" ? "" : el.style.display;
|
|
1137
1110
|
effect(() => {
|
|
1138
|
-
|
|
1139
|
-
|
|
1111
|
+
const hidden = !get();
|
|
1112
|
+
if (el._vsh && !hidden) el._vts = performance.now();
|
|
1113
|
+
el._vsh = hidden;
|
|
1114
|
+
el.style.display = hidden ? "none" : el._vod;
|
|
1140
1115
|
});
|
|
1141
1116
|
};
|
|
1142
1117
|
// src/directives/text.ts
|
|
1143
1118
|
var text = ({ el, get, effect }) => {
|
|
1119
|
+
el.__r = 1;
|
|
1144
1120
|
effect(() => {
|
|
1145
1121
|
el.textContent = toDisplayString(get());
|
|
1146
1122
|
});
|
|
@@ -1148,6 +1124,7 @@ getter: `, this.getter);
|
|
|
1148
1124
|
var toDisplayString = (value) => value == null ? "" : isArray(value) || isObject(value) && (value.toString === objectToString || !isFunction(value.toString)) ? JSON.stringify(value, null, 2) : String(value);
|
|
1149
1125
|
// src/directives/html.ts
|
|
1150
1126
|
var html = ({ el, get, effect }) => {
|
|
1127
|
+
el.__r = 1;
|
|
1151
1128
|
effect(() => {
|
|
1152
1129
|
el.innerHTML = get() ?? "";
|
|
1153
1130
|
});
|
|
@@ -1158,11 +1135,6 @@ getter: `, this.getter);
|
|
|
1158
1135
|
if (val != null) el.removeAttribute(name);
|
|
1159
1136
|
return val;
|
|
1160
1137
|
};
|
|
1161
|
-
/**
|
|
1162
|
-
* Adds a listener and returns a remover. Callers are expected to use it:
|
|
1163
|
-
* `app.unmount(el)` leaves elements in the document, so a listener left behind
|
|
1164
|
-
* would keep driving markup meant to be inert.
|
|
1165
|
-
*/
|
|
1166
1138
|
var listen = (el, event, handler, options) => {
|
|
1167
1139
|
el.addEventListener(event, handler, options);
|
|
1168
1140
|
return () => el.removeEventListener(event, handler, options);
|
|
@@ -1298,35 +1270,19 @@ getter: `, this.getter);
|
|
|
1298
1270
|
};
|
|
1299
1271
|
// src/ownership.ts
|
|
1300
1272
|
var owned = /* @__PURE__ */ new WeakMap();
|
|
1301
|
-
/**
|
|
1302
|
-
* The node currently being walked. A module-level cursor suffices because the
|
|
1303
|
-
* walk is synchronous and depth-first, and it keeps `owner` out of every
|
|
1304
|
-
* directive signature.
|
|
1305
|
-
*/
|
|
1306
1273
|
var owner;
|
|
1307
1274
|
var setOwner = (node) => {
|
|
1308
1275
|
const previous = owner;
|
|
1309
1276
|
owner = node;
|
|
1310
1277
|
return previous;
|
|
1311
1278
|
};
|
|
1312
|
-
/**
|
|
1313
|
-
* Registers a disposer against `node`, defaulting to the node being walked.
|
|
1314
|
-
* Pass `node` explicitly for a directive that outlives its element: `v-if` and
|
|
1315
|
-
* `v-for` detach the template and render from an anchor, so they must own to
|
|
1316
|
-
* the anchor.
|
|
1317
|
-
*/
|
|
1318
1279
|
var own = (dispose, node = owner) => {
|
|
1319
1280
|
if (!node) return;
|
|
1320
1281
|
const list = owned.get(node);
|
|
1321
1282
|
if (list) list.push(dispose);
|
|
1322
1283
|
else owned.set(node, [dispose]);
|
|
1323
1284
|
};
|
|
1324
|
-
/** Withdraws a disposer from `node`, for an owner that removes it itself. */
|
|
1325
1285
|
var disown = (dispose, node) => remove(owned.get(node) || [], dispose);
|
|
1326
|
-
/**
|
|
1327
|
-
* Disposes `node` and its subtree. Safe on an unowned node, and idempotent —
|
|
1328
|
-
* the record is dropped as it runs.
|
|
1329
|
-
*/
|
|
1330
1286
|
var disposeSubtree = (node) => {
|
|
1331
1287
|
const list = owned.get(node);
|
|
1332
1288
|
if (list) {
|
|
@@ -1417,7 +1373,10 @@ getter: `, this.getter);
|
|
|
1417
1373
|
}
|
|
1418
1374
|
};
|
|
1419
1375
|
let branchEffect;
|
|
1420
|
-
const stopBranches = () =>
|
|
1376
|
+
const stopBranches = () => {
|
|
1377
|
+
stopEffect(branchEffect);
|
|
1378
|
+
remove(ctx.effects, branchEffect);
|
|
1379
|
+
};
|
|
1421
1380
|
branchEffect = ctx.effect(() => {
|
|
1422
1381
|
for (let i = 0; i < branches.length; i++) {
|
|
1423
1382
|
const { exp, el } = branches[i];
|
|
@@ -1488,11 +1447,21 @@ getter: `, this.getter);
|
|
|
1488
1447
|
const createRows = (source) => {
|
|
1489
1448
|
const map = /* @__PURE__ */ new Map();
|
|
1490
1449
|
const rows = [];
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1450
|
+
try {
|
|
1451
|
+
if (isArray(source) || isString(source)) for (let i = 0; i < source.length; i++) rows.push(createRow(map, source[i], i));
|
|
1452
|
+
else if (typeof source === "number") for (let i = 0; i < source; i++) rows.push(createRow(map, i + 1, i));
|
|
1453
|
+
else if (isObject(source)) {
|
|
1454
|
+
let i = 0;
|
|
1455
|
+
for (const key in source) rows.push(createRow(map, source[key], i++, key));
|
|
1456
|
+
}
|
|
1457
|
+
} catch (e) {
|
|
1458
|
+
handleError(e, {
|
|
1459
|
+
phase: "expression",
|
|
1460
|
+
source: "v-for",
|
|
1461
|
+
el,
|
|
1462
|
+
expression: sourceExp
|
|
1463
|
+
});
|
|
1464
|
+
return [[], /* @__PURE__ */ new Map()];
|
|
1496
1465
|
}
|
|
1497
1466
|
return [rows, map];
|
|
1498
1467
|
};
|
|
@@ -1500,7 +1469,7 @@ getter: `, this.getter);
|
|
|
1500
1469
|
const data = {};
|
|
1501
1470
|
if (destructureBindings) destructureBindings.forEach((b, i) => data[b] = value?.[isArrayDestructure ? i : b]);
|
|
1502
1471
|
else data[valueExp] = value;
|
|
1503
|
-
if (objKey) {
|
|
1472
|
+
if (objKey != null) {
|
|
1504
1473
|
indexExp && (data[indexExp] = objKey);
|
|
1505
1474
|
objIndexExp && (data[objIndexExp] = index);
|
|
1506
1475
|
} else indexExp && (data[indexExp] = index);
|
|
@@ -1515,7 +1484,10 @@ getter: `, this.getter);
|
|
|
1515
1484
|
};
|
|
1516
1485
|
};
|
|
1517
1486
|
const mountBlock = (row, ref) => {
|
|
1518
|
-
const block = new Block(el, createScopedContext(ctx, row.data));
|
|
1487
|
+
const block = new Block(el, createScopedContext(ctx, row.data, true));
|
|
1488
|
+
const t = block.template;
|
|
1489
|
+
t.__ctx ??= block.ctx;
|
|
1490
|
+
block.ctx.cleanups.push(() => delete t.__ctx);
|
|
1519
1491
|
block.key = row.key;
|
|
1520
1492
|
block.insert(parent(), ref);
|
|
1521
1493
|
return block;
|
|
@@ -1569,7 +1541,9 @@ getter: `, this.getter);
|
|
|
1569
1541
|
else {
|
|
1570
1542
|
block = blocks[oldIndex];
|
|
1571
1543
|
Object.assign(block.ctx.scope, row.data);
|
|
1572
|
-
|
|
1544
|
+
let next = (block.end || block.el).nextSibling;
|
|
1545
|
+
while (next?.__leaving) next = next.nextSibling;
|
|
1546
|
+
if (oldIndex !== i && next !== ref) block.insert(parent(), ref);
|
|
1573
1547
|
}
|
|
1574
1548
|
nextBlocks[i] = nextBlock = block;
|
|
1575
1549
|
}
|
|
@@ -1586,7 +1560,7 @@ getter: `, this.getter);
|
|
|
1586
1560
|
const ref = get();
|
|
1587
1561
|
{
|
|
1588
1562
|
const existing = hasOwn(refs, ref) && refs[ref];
|
|
1589
|
-
if (existing && existing !== el && existing.isConnected) warnOnce(`ref-dup:${ref}`, `two elements claim ref="${ref}" in the same scope; $refs.${ref} points at the last one mounted and the earlier element is no longer reachable. Give each element its own name.`);
|
|
1563
|
+
if (existing && existing !== el && existing.isConnected && !existing.__leaving) warnOnce(`ref-dup:${ref}`, `two elements claim ref="${ref}" in the same scope; $refs.${ref} points at the last one mounted and the earlier element is no longer reachable. Give each element its own name.`);
|
|
1590
1564
|
}
|
|
1591
1565
|
$refs[ref] = el;
|
|
1592
1566
|
if (prevRef && ref !== prevRef && refs[prevRef] === el) delete $refs[prevRef];
|
|
@@ -1602,17 +1576,12 @@ getter: `, this.getter);
|
|
|
1602
1576
|
"idle",
|
|
1603
1577
|
"interaction"
|
|
1604
1578
|
];
|
|
1605
|
-
/** Selector matching every scope root, deferred or not. */
|
|
1606
1579
|
var SCOPE_SELECTOR = ["[v-scope]", ...LAZY_MODES.map((m) => `[v-scope\\.${m}]`)].join(",");
|
|
1607
1580
|
var INTERACTIONS = [
|
|
1608
1581
|
"pointerdown",
|
|
1609
1582
|
"keydown",
|
|
1610
1583
|
"focusin"
|
|
1611
1584
|
];
|
|
1612
|
-
/**
|
|
1613
|
-
* Arms `mode` and returns a disposer. Fires at most once; disposing first
|
|
1614
|
-
* cancels it, since a region can be unmounted while still waiting.
|
|
1615
|
-
*/
|
|
1616
1585
|
var arm = (el, mode, fire) => {
|
|
1617
1586
|
let done = false;
|
|
1618
1587
|
const once = () => {
|
|
@@ -1624,7 +1593,11 @@ getter: `, this.getter);
|
|
|
1624
1593
|
let stop = NOOP;
|
|
1625
1594
|
if (mode === "visible" && typeof IntersectionObserver == "function") {
|
|
1626
1595
|
const io = new IntersectionObserver((entries) => {
|
|
1627
|
-
|
|
1596
|
+
for (const e of entries) {
|
|
1597
|
+
if (e.isIntersecting) return once();
|
|
1598
|
+
const parent = e.target.parentElement;
|
|
1599
|
+
if (!e.boundingClientRect.width && parent) io.observe(parent);
|
|
1600
|
+
}
|
|
1628
1601
|
});
|
|
1629
1602
|
io.observe(el);
|
|
1630
1603
|
stop = () => io.disconnect();
|
|
@@ -1643,10 +1616,6 @@ getter: `, this.getter);
|
|
|
1643
1616
|
stop();
|
|
1644
1617
|
};
|
|
1645
1618
|
};
|
|
1646
|
-
/**
|
|
1647
|
-
* Returns true if `el` was deferred. The walk must not descend into it:
|
|
1648
|
-
* walking consumes directives, so it could not be walked again later.
|
|
1649
|
-
*/
|
|
1650
1619
|
var deferScope = (el, ctx, walk, once) => {
|
|
1651
1620
|
const mode = LAZY_MODES.find((m) => el.hasAttribute(`v-scope.${m}`));
|
|
1652
1621
|
if (!mode) return false;
|
|
@@ -1668,16 +1637,6 @@ getter: `, this.getter);
|
|
|
1668
1637
|
var dirRE = /^(?:v-|:|@)/;
|
|
1669
1638
|
var modifierRE = /\.([\w-]+)/g;
|
|
1670
1639
|
var inOnce = false;
|
|
1671
|
-
/**
|
|
1672
|
-
* Registers a cleanup on both owners: the context, for whole-region teardown,
|
|
1673
|
-
* and the walked node, for a subtree detached on its own. Dropping the entry
|
|
1674
|
-
* when the node goes keeps a re-mounted region from accumulating spent ones.
|
|
1675
|
-
*
|
|
1676
|
-
* The `indexOf` guard also makes this run-once. A subtree can reach the same
|
|
1677
|
-
* cleanup twice — via the block root, whose teardown drains `ctx.cleanups`,
|
|
1678
|
-
* and via the node — and a second run would remove a listener the next mount
|
|
1679
|
-
* installed.
|
|
1680
|
-
*/
|
|
1681
1640
|
var addCleanup = (ctx, cleanup, node) => {
|
|
1682
1641
|
ctx.cleanups.push(cleanup);
|
|
1683
1642
|
own(() => {
|
|
@@ -1707,16 +1666,17 @@ getter: `, this.getter);
|
|
|
1707
1666
|
}
|
|
1708
1667
|
};
|
|
1709
1668
|
var walkNode = (node, ctx) => {
|
|
1669
|
+
if (node.__r) return;
|
|
1710
1670
|
const type = node.nodeType;
|
|
1711
1671
|
if (type === 1) {
|
|
1712
1672
|
const el = node;
|
|
1713
1673
|
if (!el.hasAttributes()) return walkChildren(el, ctx);
|
|
1714
1674
|
if (el.hasAttribute("v-pre")) return;
|
|
1715
|
-
if (deferScope(el, ctx, walkDeferred, inOnce)) return;
|
|
1716
|
-
checkAttr(el, "v-cloak");
|
|
1717
1675
|
let exp;
|
|
1718
1676
|
if ((exp = checkAttr(el, "v-if")) != null) return _if(el, exp, ctx);
|
|
1719
1677
|
if (exp = checkAttr(el, "v-for")) return _for(el, exp, ctx);
|
|
1678
|
+
if (deferScope(el, ctx, walkDeferred, inOnce)) return;
|
|
1679
|
+
checkAttr(el, "v-cloak");
|
|
1720
1680
|
const name = checkAttr(el, "v-name");
|
|
1721
1681
|
let teleportNext;
|
|
1722
1682
|
if (exp = checkAttr(el, "v-teleport")) {
|
|
@@ -1725,7 +1685,16 @@ getter: `, this.getter);
|
|
|
1725
1685
|
teleportNext = el.nextSibling;
|
|
1726
1686
|
const marker = el.__marker = new Text("");
|
|
1727
1687
|
el.before(marker);
|
|
1728
|
-
|
|
1688
|
+
try {
|
|
1689
|
+
target.appendChild(el);
|
|
1690
|
+
} catch (e) {
|
|
1691
|
+
handleError(e, {
|
|
1692
|
+
phase: "directive",
|
|
1693
|
+
source: "v-teleport",
|
|
1694
|
+
el,
|
|
1695
|
+
expression: exp
|
|
1696
|
+
});
|
|
1697
|
+
}
|
|
1729
1698
|
addCleanup(ctx, () => {
|
|
1730
1699
|
disposeSubtree(el);
|
|
1731
1700
|
el.remove();
|
|
@@ -1749,7 +1718,7 @@ getter: `, this.getter);
|
|
|
1749
1718
|
const wasOnce = inOnce;
|
|
1750
1719
|
if (checkAttr(el, "v-once") != null) inOnce = true;
|
|
1751
1720
|
if (exp = checkAttr(el, "ref")) applyDirective(el, ref, `"${exp}"`, ctx);
|
|
1752
|
-
walkChildren(el, ctx);
|
|
1721
|
+
if (!el.hasAttribute("v-text") && !el.hasAttribute("v-html")) walkChildren(el, ctx);
|
|
1753
1722
|
const deferred = [];
|
|
1754
1723
|
for (const { name, value } of [...el.attributes]) if (dirRE.test(name) && name !== "v-cloak") {
|
|
1755
1724
|
if (name === "v-model" || name.startsWith("v-model.")) deferred.unshift([name, value]);
|
|
@@ -1761,7 +1730,7 @@ getter: `, this.getter);
|
|
|
1761
1730
|
return teleportNext;
|
|
1762
1731
|
} else if (type === 3) {
|
|
1763
1732
|
const data = node.data;
|
|
1764
|
-
if (data.includes(ctx.delimiters[0]) &&
|
|
1733
|
+
if (data.includes(ctx.delimiters[0]) && node.parentNode?.localName != "script") {
|
|
1765
1734
|
let segments = [];
|
|
1766
1735
|
let lastIndex = 0;
|
|
1767
1736
|
let match;
|
|
@@ -1819,7 +1788,7 @@ getter: `, this.getter);
|
|
|
1819
1788
|
const meta = {
|
|
1820
1789
|
source,
|
|
1821
1790
|
el,
|
|
1822
|
-
expression: displayExp
|
|
1791
|
+
expression: displayExp || exp
|
|
1823
1792
|
};
|
|
1824
1793
|
const report = (err) => handleError(err, {
|
|
1825
1794
|
phase: "handler",
|
|
@@ -1863,12 +1832,19 @@ getter: `, this.getter);
|
|
|
1863
1832
|
});
|
|
1864
1833
|
return;
|
|
1865
1834
|
}
|
|
1866
|
-
if (cleanup) addCleanup(ctx,
|
|
1835
|
+
if (cleanup) addCleanup(ctx, () => {
|
|
1836
|
+
try {
|
|
1837
|
+
cleanup();
|
|
1838
|
+
} catch (e) {
|
|
1839
|
+
handleError(e, {
|
|
1840
|
+
phase: "teardown",
|
|
1841
|
+
source,
|
|
1842
|
+
el,
|
|
1843
|
+
expression: exp
|
|
1844
|
+
});
|
|
1845
|
+
}
|
|
1846
|
+
});
|
|
1867
1847
|
};
|
|
1868
|
-
/**
|
|
1869
|
-
* `querySelector` for a selector written in markup. One that does not parse is
|
|
1870
|
-
* reported and yields undefined, rather than throwing out of `mount()`.
|
|
1871
|
-
*/
|
|
1872
1848
|
var query = (sel, el, source) => {
|
|
1873
1849
|
try {
|
|
1874
1850
|
return document.querySelector(sel);
|
|
@@ -1888,7 +1864,7 @@ getter: `, this.getter);
|
|
|
1888
1864
|
if (templateEl !== void 0) console.error(`template selector ${template} has no matching <template> element.`);
|
|
1889
1865
|
return;
|
|
1890
1866
|
}
|
|
1891
|
-
el.appendChild(templateEl.content
|
|
1867
|
+
el.appendChild(el.ownerDocument.importNode(templateEl.content, true));
|
|
1892
1868
|
return;
|
|
1893
1869
|
}
|
|
1894
1870
|
el.innerHTML = template;
|
|
@@ -1925,17 +1901,12 @@ getter: `, this.getter);
|
|
|
1925
1901
|
};
|
|
1926
1902
|
return ctx;
|
|
1927
1903
|
};
|
|
1928
|
-
/**
|
|
1929
|
-
* Framework-provided, so non-enumerable: `Object.assign`-ing one scope onto
|
|
1930
|
-
* another must copy the user's data and leave these alone. v-for does exactly
|
|
1931
|
-
* that on every update, which reset each row's $id and wiped its $refs.
|
|
1932
|
-
*/
|
|
1933
1904
|
var hide = (scope, key, value) => Object.defineProperty(scope, key, {
|
|
1934
1905
|
value,
|
|
1935
1906
|
writable: true,
|
|
1936
1907
|
configurable: true
|
|
1937
1908
|
});
|
|
1938
|
-
var createScopedContext = (ctx, data = {}) => {
|
|
1909
|
+
var createScopedContext = (ctx, data = {}, isRow) => {
|
|
1939
1910
|
const parentScope = ctx.scope;
|
|
1940
1911
|
const mergedScope = Object.create(parentScope);
|
|
1941
1912
|
Object.defineProperties(mergedScope, Object.getOwnPropertyDescriptors(data));
|
|
@@ -1950,16 +1921,20 @@ getter: `, this.getter);
|
|
|
1950
1921
|
};
|
|
1951
1922
|
hide(mergedScope, "$watch", createWatch(scopedCtx));
|
|
1952
1923
|
hide(mergedScope, "$id", createId());
|
|
1953
|
-
bindContextMethods(reactiveProxy, mergedScope);
|
|
1924
|
+
if (!isRow) bindContextMethods(reactiveProxy, mergedScope);
|
|
1954
1925
|
return scopedCtx;
|
|
1955
1926
|
};
|
|
1956
1927
|
var bindContextMethods = (scope, raw = scope) => {
|
|
1957
1928
|
for (const key of Object.keys(raw)) {
|
|
1958
|
-
const fn = Object.getOwnPropertyDescriptor(raw, key)
|
|
1959
|
-
if (typeof fn === "function") scope[key] = fn.bind(scope);
|
|
1929
|
+
const { value: fn, writable } = Object.getOwnPropertyDescriptor(raw, key);
|
|
1930
|
+
if (typeof fn === "function" && writable) scope[key] = Object.setPrototypeOf(fn.bind(scope), fn);
|
|
1960
1931
|
}
|
|
1961
1932
|
};
|
|
1962
1933
|
// src/block.ts
|
|
1934
|
+
var stopEffects = (block) => {
|
|
1935
|
+
block.ctx.blocks.forEach(stopEffects);
|
|
1936
|
+
block.ctx.effects.splice(0).forEach(stopEffect);
|
|
1937
|
+
};
|
|
1963
1938
|
var Block = class {
|
|
1964
1939
|
get el() {
|
|
1965
1940
|
return this.start || this.template.__marker || this.template;
|
|
@@ -1967,7 +1942,10 @@ getter: `, this.getter);
|
|
|
1967
1942
|
constructor(template, parentCtx, isRoot = false) {
|
|
1968
1943
|
this.isFragment = template instanceof HTMLTemplateElement;
|
|
1969
1944
|
if (isRoot) this.template = template;
|
|
1970
|
-
else if (
|
|
1945
|
+
else if (template.hasAttribute("v-for")) {
|
|
1946
|
+
this.isFragment = true;
|
|
1947
|
+
(this.template = new DocumentFragment()).append(template.cloneNode(true));
|
|
1948
|
+
} else if (this.isFragment) this.template = template.ownerDocument.importNode(template.content, true);
|
|
1971
1949
|
else this.template = template.cloneNode(true);
|
|
1972
1950
|
if (isRoot) this.ctx = createContext(parentCtx);
|
|
1973
1951
|
else {
|
|
@@ -2002,7 +1980,10 @@ getter: `, this.getter);
|
|
|
2002
1980
|
}
|
|
2003
1981
|
}
|
|
2004
1982
|
remove() {
|
|
2005
|
-
if (this.parentCtx)
|
|
1983
|
+
if (this.parentCtx) {
|
|
1984
|
+
remove(this.parentCtx.blocks, this);
|
|
1985
|
+
this.parentCtx = void 0;
|
|
1986
|
+
}
|
|
2006
1987
|
const removeNow = () => {
|
|
2007
1988
|
const parent = this.start ? this.start.parentNode : this.template.parentNode;
|
|
2008
1989
|
if (parent) {
|
|
@@ -2024,9 +2005,11 @@ getter: `, this.getter);
|
|
|
2024
2005
|
this.template.__marker?.remove();
|
|
2025
2006
|
this.teardown();
|
|
2026
2007
|
};
|
|
2008
|
+
stopEffects(this);
|
|
2027
2009
|
const leaves = [];
|
|
2028
2010
|
let node = this.start || this.template;
|
|
2029
2011
|
while (node) {
|
|
2012
|
+
node.__leaving = 1;
|
|
2030
2013
|
const leave = node.__leave;
|
|
2031
2014
|
if (leave) leaves.push(leave());
|
|
2032
2015
|
if (!this.start || node === this.end) break;
|
|
@@ -2035,10 +2018,6 @@ getter: `, this.getter);
|
|
|
2035
2018
|
if (leaves.length) Promise.all(leaves).then(removeNow);
|
|
2036
2019
|
else removeNow();
|
|
2037
2020
|
}
|
|
2038
|
-
/**
|
|
2039
|
-
* The bookkeeping half of `remove()`, for a block whose nodes are already
|
|
2040
|
-
* gone — `remove()`'s `removeChild` calls would throw on them.
|
|
2041
|
-
*/
|
|
2042
2021
|
discard() {
|
|
2043
2022
|
if (this.parentCtx) remove(this.parentCtx.blocks, this);
|
|
2044
2023
|
this.teardown();
|
|
@@ -2052,24 +2031,10 @@ getter: `, this.getter);
|
|
|
2052
2031
|
}
|
|
2053
2032
|
};
|
|
2054
2033
|
// src/store.ts
|
|
2055
|
-
/**
|
|
2056
|
-
* DEV: catch `$store.typo`, which otherwise reads as `undefined` and renders a
|
|
2057
|
-
* blank instead of raising.
|
|
2058
|
-
*
|
|
2059
|
-
* The trap sits *under* `reactive`, not over it: `reactive` probes its target
|
|
2060
|
-
* for `__v_raw`, and a wrapper that forwards that probe is bypassed entirely.
|
|
2061
|
-
* `__v_`-prefixed keys are ignored for the same reason — they are not reads a
|
|
2062
|
-
* user wrote.
|
|
2063
|
-
*
|
|
2064
|
-
* Deferred to the end of the task, because reading a store before it is
|
|
2065
|
-
* registered is legitimate — the registry is reactive so the expression
|
|
2066
|
-
* re-runs. A microtask would warn on a store registered after an `await`. One
|
|
2067
|
-
* registered later still warns; a check cannot wait forever.
|
|
2068
|
-
*/
|
|
2069
2034
|
var registry = Object.create(null);
|
|
2070
2035
|
var target = registry;
|
|
2071
2036
|
target = new Proxy(registry, { get(obj, key, receiver) {
|
|
2072
|
-
if (typeof key === "string" && !key.startsWith("__") && key !== "toJSON" && !(key in obj)) setTimeout(() => {
|
|
2037
|
+
if (typeof key === "string" && !key.startsWith("__") && key !== "toJSON" && !(key in obj) && !(key in Object.prototype)) setTimeout(() => {
|
|
2073
2038
|
if (key in obj) return;
|
|
2074
2039
|
warnOnce(`store-missing:${key}`, `$store.${key} is not registered, so it reads as undefined. Register it with store('${key}', { … }) before mounting, or check the spelling.`);
|
|
2075
2040
|
});
|
|
@@ -2092,6 +2057,7 @@ getter: `, this.getter);
|
|
|
2092
2057
|
// src/app.ts
|
|
2093
2058
|
var mountedRoots = /* @__PURE__ */ new WeakMap();
|
|
2094
2059
|
var escapeRegex = (str) => str.replace(/[-.*+?^${}()|[\]/\\]/g, "\\$&");
|
|
2060
|
+
var isInert = (el) => el && (el.__r || el.hasAttribute("v-pre") || isInert(el.parentElement));
|
|
2095
2061
|
var createApp = (initialData) => {
|
|
2096
2062
|
const ctx = createContext();
|
|
2097
2063
|
if (typeof initialData === "function") {
|
|
@@ -2186,28 +2152,25 @@ getter: `, this.getter);
|
|
|
2186
2152
|
if (el.matches(SCOPE_SELECTOR)) roots = [el];
|
|
2187
2153
|
else roots = [...el.querySelectorAll(SCOPE_SELECTOR)].filter((root) => !root.matches(`:where(${SCOPE_SELECTOR}) *`));
|
|
2188
2154
|
if (!roots.length) roots = [el];
|
|
2155
|
+
roots = roots.filter((root) => !isInert(root));
|
|
2189
2156
|
if (roots.length === 1 && roots[0] === document.documentElement) console.warn("Mounting on documentElement - this is non-optimal as LiteVue will be forced to crawl the entire page's DOM. Consider explicitly marking elements controlled by LiteVue with `v-scope`.");
|
|
2190
2157
|
ctx.walk ??= walk;
|
|
2191
2158
|
ctx.dispose ??= disposeSubtree;
|
|
2192
2159
|
for (const el of roots) {
|
|
2193
2160
|
if (mountedRoots.has(el) && mountedRoots.get(el) === el.firstChild) warn("mount() was called again on an element that has already been mounted, so its directives were consumed by the first walk and nothing was bound this time. To re-activate a region, insert fresh markup and mount that instead.");
|
|
2194
2161
|
const name = el.getAttribute("v-name");
|
|
2162
|
+
const host = el.parentNode;
|
|
2195
2163
|
const block = new Block(el, ctx, true);
|
|
2164
|
+
block.host = host;
|
|
2196
2165
|
mountedRoots.set(el, el.firstChild);
|
|
2197
2166
|
el.__ctx ??= block.ctx;
|
|
2198
2167
|
if (!devtools.scopes.has(el) && !el.matches(SCOPE_SELECTOR)) block.ctx.cleanups.push(registerScope(el, block.ctx.scope, void 0, name || void 0));
|
|
2199
2168
|
rootBlocks.push(block);
|
|
2200
|
-
own(() => remove(rootBlocks, block), el);
|
|
2169
|
+
own(() => (remove(rootBlocks, block), block.teardown()), el);
|
|
2201
2170
|
block.ctx.cleanups.push(() => delete el.__ctx);
|
|
2202
2171
|
}
|
|
2203
2172
|
return this;
|
|
2204
2173
|
},
|
|
2205
|
-
/**
|
|
2206
|
-
* Tear down mounted regions: every root, or only those at or inside `el`.
|
|
2207
|
-
* Effects stop, cleanups run and scopes deregister; the rest of the app
|
|
2208
|
-
* keeps running. Without it, replacing a region's markup leaves its
|
|
2209
|
-
* effects writing to detached nodes.
|
|
2210
|
-
*/
|
|
2211
2174
|
unmount(el) {
|
|
2212
2175
|
if (el == null) {
|
|
2213
2176
|
rootBlocks.forEach((block) => block.teardown());
|
|
@@ -2236,7 +2199,7 @@ getter: `, this.getter);
|
|
|
2236
2199
|
const kept = [];
|
|
2237
2200
|
for (const block of rootBlocks) {
|
|
2238
2201
|
const root = block.template;
|
|
2239
|
-
if (target.contains(root)) block.teardown();
|
|
2202
|
+
if (target.contains(root) || target.contains(block.host)) block.teardown();
|
|
2240
2203
|
else kept.push(block);
|
|
2241
2204
|
}
|
|
2242
2205
|
if (kept.length === rootBlocks.length) console.warn("unmount: no mounted region found at or inside the given element. Pass the same element that was mounted, or one containing it.");
|