Files
2026-08-10 18:50:14 +08:00

159 lines
5.5 KiB
Diff

diff --git a/es/clickoutside.js b/es/clickoutside.js
index 3dcb41588ad00463f58be7c972882bc9d49c0f06..eef77f163c02a525f2810ab9294cb4179c3bac97 100644
--- a/es/clickoutside.js
+++ b/es/clickoutside.js
@@ -13,6 +13,12 @@ const clickoutside = {
}
},
updated(el, { value, modifiers }) {
+ // patched: `updated` may fire without `mounted` (teleport remount), initialize lazily
+ if (!el[ctxKey]) {
+ el[ctxKey] = {
+ handler: undefined
+ };
+ }
const ctx = el[ctxKey];
if (typeof value === 'function') {
if (ctx.handler) {
@@ -43,6 +49,8 @@ const clickoutside = {
}
},
unmounted(el, { modifiers }) {
+ if (!el[ctxKey])
+ return;
const { handler } = el[ctxKey];
if (handler) {
off('clickoutside', el, handler, {
diff --git a/es/mousemoveoutside.js b/es/mousemoveoutside.js
index f15be455deb61f8af83abc285b46f7931fd1cb06..2f2c6ffe9c33ace8e23dc3c51d75420dc563e95e 100644
--- a/es/mousemoveoutside.js
+++ b/es/mousemoveoutside.js
@@ -11,6 +11,12 @@ const mousemoveoutside = {
}
},
updated(el, { value }) {
+ // patched: `updated` may fire without `mounted` (teleport remount), initialize lazily
+ if (!el[ctxKey]) {
+ el[ctxKey] = {
+ handler: undefined
+ };
+ }
const ctx = el[ctxKey];
if (typeof value === 'function') {
if (ctx.handler) {
@@ -33,6 +39,8 @@ const mousemoveoutside = {
}
},
unmounted(el) {
+ if (!el[ctxKey])
+ return;
const { handler } = el[ctxKey];
if (handler) {
off('mousemoveoutside', el, handler);
diff --git a/es/zindexable/index.js b/es/zindexable/index.js
index 8066b8c39003c8b09419586b125c5b866eb5c788..b7680bedb5823c2464305081164284c189a426b1 100644
--- a/es/zindexable/index.js
+++ b/es/zindexable/index.js
@@ -17,6 +17,13 @@ const zindexable = {
updated(el, bindings) {
const { value = {} } = bindings;
const { zIndex, enabled } = value;
+ // patched: `updated` may fire without `mounted` (teleport remount), initialize lazily
+ if (!el[ctx]) {
+ el[ctx] = {
+ enabled: false,
+ initialized: false
+ };
+ }
const cachedEnabled = el[ctx].enabled;
if (enabled && !cachedEnabled) {
zIndexManager.ensureZIndex(el, zIndex);
@@ -25,7 +32,7 @@ const zindexable = {
el[ctx].enabled = !!enabled;
},
unmounted(el, bindings) {
- if (!el[ctx].initialized)
+ if (!el[ctx] || !el[ctx].initialized)
return;
const { value = {} } = bindings;
const { zIndex } = value;
diff --git a/lib/clickoutside.js b/lib/clickoutside.js
index 300e65614d1789e1ee477460b58b88aab94b6588..af39ce4e8b5deac36fac9ea8560aba676e852a54 100644
--- a/lib/clickoutside.js
+++ b/lib/clickoutside.js
@@ -15,6 +15,12 @@ const clickoutside = {
}
},
updated(el, { value, modifiers }) {
+ // patched: `updated` may fire without `mounted` (teleport remount), initialize lazily
+ if (!el[ctxKey]) {
+ el[ctxKey] = {
+ handler: undefined
+ };
+ }
const ctx = el[ctxKey];
if (typeof value === 'function') {
if (ctx.handler) {
@@ -45,6 +51,8 @@ const clickoutside = {
}
},
unmounted(el, { modifiers }) {
+ if (!el[ctxKey])
+ return;
const { handler } = el[ctxKey];
if (handler) {
(0, evtd_1.off)('clickoutside', el, handler, {
diff --git a/lib/mousemoveoutside.js b/lib/mousemoveoutside.js
index daf5afa22dd0a715c91bf81703161878ffbfb6fd..1608823f4257d924e870710bf55a295255948d74 100644
--- a/lib/mousemoveoutside.js
+++ b/lib/mousemoveoutside.js
@@ -13,6 +13,12 @@ const mousemoveoutside = {
}
},
updated(el, { value }) {
+ // patched: `updated` may fire without `mounted` (teleport remount), initialize lazily
+ if (!el[ctxKey]) {
+ el[ctxKey] = {
+ handler: undefined
+ };
+ }
const ctx = el[ctxKey];
if (typeof value === 'function') {
if (ctx.handler) {
@@ -35,6 +41,8 @@ const mousemoveoutside = {
}
},
unmounted(el) {
+ if (!el[ctxKey])
+ return;
const { handler } = el[ctxKey];
if (handler) {
(0, evtd_1.off)('mousemoveoutside', el, handler);
diff --git a/lib/zindexable/index.js b/lib/zindexable/index.js
index ac608e9c13376a0e21f9fea8802c1d7bfb9d1c58..9305912d112a91dc0f6eb354bb2aaa95b3351dca 100644
--- a/lib/zindexable/index.js
+++ b/lib/zindexable/index.js
@@ -19,6 +19,13 @@ const zindexable = {
updated(el, bindings) {
const { value = {} } = bindings;
const { zIndex, enabled } = value;
+ // patched: `updated` may fire without `mounted` (teleport remount), initialize lazily
+ if (!el[ctx]) {
+ el[ctx] = {
+ enabled: false,
+ initialized: false
+ };
+ }
const cachedEnabled = el[ctx].enabled;
if (enabled && !cachedEnabled) {
z_index_manager_1.default.ensureZIndex(el, zIndex);
@@ -27,7 +34,7 @@ const zindexable = {
el[ctx].enabled = !!enabled;
},
unmounted(el, bindings) {
- if (!el[ctx].initialized)
+ if (!el[ctx] || !el[ctx].initialized)
return;
const { value = {} } = bindings;
const { zIndex } = value;