Created
May 4, 2012 10:46
-
-
Save albburtsev/2594062 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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