public
Last active

Element.disposeSelf and Element.destroySelf - removes an element without removing its content

  • Download Gist
Element.disposeSelf.destroySelf.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
(function(){
 
var moveContent = function(element){
var nodes = $A(element.childNodes);
var parent = element.parentNode;
for (var i=0, l=nodes.length; i<l; i++){
parent.insertBefore(nodes[i], element);
}
};
 
Element.implement({
 
disposeSelf: function(){
moveContent(this);
return this.dispose();
},
destroySelf: function(){
moveContent(this);
return this.destroy();
}
 
});
 
})();

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.