From e83a80916c27bbcd0093f4640f1e9ac65b69937e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=E5=B1=8F=E5=B1=B1=E6=9C=80=E9=80=9F=E4=B8=8B?= =?UTF-8?q?=E5=B1=B1=E4=BC=A0=E8=AF=B4?= Date: Mon, 25 Mar 2024 15:04:43 +0800 Subject: [PATCH] =?UTF-8?q?KERNEL-17875=20fix:=20fineui=20Dep=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E5=9B=9E=E6=94=B6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/fineui/src/fix/fix.compact.js | 15 ++++++++------- packages/fineui/src/fix/fix.js | 10 +++++++++- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/packages/fineui/src/fix/fix.compact.js b/packages/fineui/src/fix/fix.compact.js index 40b02fe8f..e76aea6a4 100644 --- a/packages/fineui/src/fix/fix.compact.js +++ b/packages/fineui/src/fix/fix.compact.js @@ -76,7 +76,7 @@ function popTarget() { export const Model = Fix.Model; const oldWatch = Fix.watch; -Fix.watch = function(model, expOrFn, cb, options) { +Fix.watch = function (model, expOrFn, cb, options) { if (isPlainObject(cb)) { options = cb; cb = cb.handler; @@ -89,7 +89,7 @@ Fix.watch = function(model, expOrFn, cb, options) { this, model, expOrFn, - function() { + function () { options && options.store && pushTarget(options.store); let res; try { @@ -167,7 +167,7 @@ export function createStore() { } const _init = Widget.prototype._init; -Widget.prototype._init = function() { +Widget.prototype._init = function () { const needPop = createStore.call(this); try { _init.apply(this, arguments); @@ -178,7 +178,7 @@ Widget.prototype._init = function() { }; const __initWatch = Widget.prototype.__initWatch; -Widget.prototype.__initWatch = function() { +Widget.prototype.__initWatch = function () { __initWatch.apply(this, arguments); const workerMode = Providers.getProvider("bi.provider.system").getWorkerMode(); @@ -191,7 +191,7 @@ Widget.prototype.__initWatch = function() { }; const unMount = Widget.prototype.__destroy; -Widget.prototype.__destroy = function() { +Widget.prototype.__destroy = function () { try { unMount.apply(this, arguments); } catch (e) { @@ -204,6 +204,7 @@ Widget.prototype.__destroy = function() { unwatch(); }); }); + Fix.cleanupDeps(); this._watchers && (this._watchers = []); if (this.store) { this.store._parent && (this.store._parent = null); @@ -213,7 +214,7 @@ Widget.prototype.__destroy = function() { delete this.__cacheStore; }; -Widget.prototype.__watch = function(getter, handler, options) { +Widget.prototype.__watch = function (getter, handler, options) { this._watchers = this._watchers || []; const watcher = new Fix.Watcher( null, @@ -235,7 +236,7 @@ Widget.prototype.__watch = function(getter, handler, options) { _.each(["_render", "__afterRender", "_mount", "__afterMount"], (name) => { const old = Widget.prototype[name]; old && - (Widget.prototype[name] = function() { + (Widget.prototype[name] = function () { this.store && pushTarget(this.store); let res; try { diff --git a/packages/fineui/src/fix/fix.js b/packages/fineui/src/fix/fix.js index ac7a8b839..51e550ae0 100644 --- a/packages/fineui/src/fix/fix.js +++ b/packages/fineui/src/fix/fix.js @@ -110,7 +110,15 @@ function isExtensible(obj) { function remove(arr, item) { - if (arr && arr.length) { + if (!arr) { + return; + } + const len = arr.length; + if (len) { + if (item === arr[len - 1]) { + arr.length = len - 1; + return; + } const index = arr.indexOf(item); if (index > -1) { return arr.splice(index, 1);