This commit is contained in:
2021-12-16 16:16:45 +03:00
parent 636cd65c78
commit 931ce4c7f7
+30 -2
View File
@@ -200,7 +200,34 @@ __PluginManager__.register('support', function(module, exports, require, global)
}
return true;
}
function insertAfter(newNode, referenceNode) {
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
}
function tagName(node, tagName) {
if(!tagName) {
return null;
}
node = getNode(node);
if(!isNode(node)) {
return null;
}
if(node.tagName.toUpperCase() === tagName.toUpperCase()) {
return node;
}
var result = document.createElement(tagName);
var childNodes = [].slice.call(node.childNodes);
for (var i = 0; i < [].slice.call(childNodes).length; i++) {
result.appendChild(childNodes[i]);
}
node.getAttributeNames().forEach(function (attrName) {
result.setAttribute(attrName, node.getAttribute(attrName))
});
if(node.parentNode){
node.parentNode.insertBefore(result, node.nextSibling);
node.remove();
}
return result;
}
/**
* @memberOf kit
@@ -230,7 +257,8 @@ __PluginManager__.register('support', function(module, exports, require, global)
definePropertyGet,
args2array,
innerHtml,
makeNodeList
makeNodeList,
tagName
};
return module.exports = support;