From b765afb9a7542551782c2d2bae32ea1ad988e979 Mon Sep 17 00:00:00 2001 From: guy Date: Sat, 27 Mar 2021 12:34:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/plugin.js | 4 ++++ src/core/shortcut.js | 28 ++++++++++++++++------------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/core/plugin.js b/src/core/plugin.js index 31d460d16..e7a3f4714 100644 --- a/src/core/plugin.js +++ b/src/core/plugin.js @@ -81,6 +81,10 @@ BI.Plugin = BI.Plugin || {}; return res || object; }, + hasObject: function (type) { + return __GlobalObjectConfigFns.length > 0 || !!_ObjectPlugin[type]; + }, + registerObject: function (type, fn) { if (!_ObjectPlugin[type]) { _ObjectPlugin[type] = []; diff --git a/src/core/shortcut.js b/src/core/shortcut.js index aa4a3b916..54af3bdbe 100644 --- a/src/core/shortcut.js +++ b/src/core/shortcut.js @@ -57,12 +57,14 @@ el = BI.extend({}, options, item); w = BI.Plugin.getWidget(el.type, el); if (w.type === el.type) { - w.listeners = (w.listeners || []).concat([{ - eventName: BI.Events.MOUNT, - action: function () { - BI.Plugin.getObject(el.type, this); - } - }]); + if (BI.Plugin.hasObject(el.type)) { + w.listeners = (w.listeners || []).concat([{ + eventName: BI.Events.MOUNT, + action: function () { + BI.Plugin.getObject(el.type, this); + } + }]); + } return createWidget(w, context, lazy); } return BI.createWidget(w, options, context, lazy); @@ -71,12 +73,14 @@ el = BI.extend({}, options, item.el); w = BI.Plugin.getWidget(el.type, el); if (w.type === el.type) { - w.listeners = (w.listeners || []).concat([{ - eventName: BI.Events.MOUNT, - action: function () { - BI.Plugin.getObject(el.type, this); - } - }]); + if (BI.Plugin.hasObject(el.type)) { + w.listeners = (w.listeners || []).concat([{ + eventName: BI.Events.MOUNT, + action: function () { + BI.Plugin.getObject(el.type, this); + } + }]); + } return createWidget(w, context, lazy); } return BI.createWidget(w, options, context, lazy);