Skip to content

Instantly share code, notes, and snippets.

@albburtsev
Created May 4, 2012 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save albburtsev/2594062 to your computer and use it in GitHub Desktop.
Save albburtsev/2594062 to your computer and use it in GitHub Desktop.
var
/**
* @constructor
* @description Базовый класс, от которого наследуется деструктор объектов
*/
Root = function() {
};
Root.prototype = {
/**
* @description Удаляет все св-ва объекта, очищает DOM-дерево без проверки вложенности, обнуляет ссылку __proto__ при возможности
*/
destroy: function() {
var i, node;
for (i in this) {
if ( this.hasOwnProperty(i) ) {
node = this[i];
if ( node && node.nodeType && node.parentNode )
node.parentNode.removeChild(node);
delete this[i];
}
}
if ( this.__proto__ )
this.__proto__ = null;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment