3 examples of 'javascript destructor' in JavaScript

Every line of 'javascript destructor' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
34destroy() {
35 if (this.callback) {
36 this.callback.call(this.scope || this);
37 }
38}
122function callDestroy(context) {
123 context.app.emit('componentDestroy', context);
124
125 //delete context.app._componentsByUId[context.uId];
126 const style = document.getElementById(context.uId + '--style');
127 if (style) {
128 style.parentNode.removeChild(style);
129 }
130
131 if (context.store && context.app._stores[context.store])
132 delete context.app._stores[context.store];
133
134 if (context._unmountedPlaceholder && context._unmountedPlaceholder.parentNode)
135 context._unmountedPlaceholder.parentNode.removeChild(context._unmountedPlaceholder);
136
137 if (context.id && context.app._ids[context.id])
138 delete context.app._ids[context.id];
139 if (typeof context.onDestroy === 'function' && context.parent && typeof context.parent[context.__onDestroy] === 'function') {
140 context.onDestroy.call(context);
141 context.parent[context.__onDestroy].call(context.parent, context);
142 context = null;
143 } else if (typeof context.onDestroy === 'function') {
144 context.onDestroy.call(context);
145 context = null;
146 } else if (context.parent && typeof context.parent[context.__onDestroy] === 'function') {
147 context.parent[context.__onDestroy].call(context.parent, context);
148 context = null;
149 }
150
151}
14_destructor() {
15 if (this.parent !== null) {
16 let index = this.parent.children.indexOf(this);
17 if (index !== 0) {
18 let last = this.parent.children[index - 1] as LinkedTreeNode;
19 last.nextNode = this.nextNode;
20 }
21 }
22 this.nextNode = null;
23 super._destructor();
24}

Related snippets