This commit is contained in:
2021-11-29 21:18:18 +03:00
parent 7c096e52d3
commit 8be41809a5
6 changed files with 71 additions and 32 deletions
+5 -20
View File
@@ -438,8 +438,7 @@ __PluginManager__.register('menu',function(module, exports, require, global) {
this.node = document.createElement('a');
this.node.style.position = 'relative';
this.node.dataset.parentId = this.parentId;
this.node.kit = this.node.kit || {};
this.node.kit.menuItem = this;
support.setNodeData(this.node, 'menuItem', this);
};
/**
@@ -627,23 +626,12 @@ __PluginManager__.register('menu',function(module, exports, require, global) {
};
/**
* @param node HTMLElement
* @param selector HTMLElement | string
* @param content HTMLElement | string
* @param isText boolean
* @return boolean
*/
MenuItem.prototype.setContent = function(node, content, isText = false){
if(!(node instanceof Element)) {
return false;
}
while (node.firstChild) {
node.removeChild(node.firstChild);
}
if((content instanceof Element) || isText) {
node.append(content);
} else {
node.innerHTML = content;
}
MenuItem.prototype.setContent = function(selector, content){
support.innerHtml(selector, content);
return true;
};
@@ -655,10 +643,7 @@ __PluginManager__.register('menu',function(module, exports, require, global) {
if(typeof options === 'string') {
options = document.querySelector(options);
}
if((options instanceof HTMLElement) && options.kit && options.kit.menu) {
return options.kit.menu;
}
return new Menu(options, items);
return support.getNodeData(options, MENU_PLUGIN_NAME) || new Menu(options, items);
};
var getActiveMenuDataList = function(){