Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit cfd3009

Browse files
acekatlinkesch
authored andcommitted
avoid error on editorDestroy and editorSetup (#310)
In my case I share one instance of MediumEditor between différent DOM elements and some of these elements have the InsertPlugin initialized and others don't. So when you destroy/setup the MediumEditor instance, it fails at disabling/enabling the InsertPlugin for the elements that don't have the plugin initialized ($(el).data('plugin_' + pluginName) is undefined).
1 parent 1a6228c commit cfd3009

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/js/core.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@
158158

159159
Core.prototype.editorDestroy = function () {
160160
$.each(this.elements, function (key, el) {
161-
$(el).data('plugin_' + pluginName).disable();
161+
if ($(el).data('plugin_' + pluginName) instanceof Core) {
162+
$(el).data('plugin_' + pluginName).disable();
163+
}
162164
});
163165

164166
this._destroy();
@@ -174,7 +176,9 @@
174176
this._setup();
175177

176178
$.each(this.elements, function (key, el) {
177-
$(el).data('plugin_' + pluginName).enable();
179+
if ($(el).data('plugin_' + pluginName) instanceof Core) {
180+
$(el).data('plugin_' + pluginName).enable();
181+
}
178182
});
179183
};
180184

0 commit comments

Comments
 (0)