MCPcopy
hub / github.com/aframevr/aframe / removeComponent

Method removeComponent

src/core/a-entity.js:347–377  ·  view source on GitHub ↗
(name, destroy)

Source from the content-addressed store, hash-verified

345 }
346
347 removeComponent (name, destroy) {
348 var component;
349
350 component = this.components[name];
351 if (!component) { return; }
352
353 // Wait for component to initialize.
354 if (!component.initialized) {
355 this.addEventListener('componentinitialized', function tryRemoveLater (evt) {
356 if (evt.detail.name !== name) { return; }
357 this.removeComponent(name, destroy);
358 this.removeEventListener('componentinitialized', tryRemoveLater);
359 });
360 return;
361 }
362
363 component.pause();
364 component.remove();
365
366 // Keep component attached to entity in case of just full entity detach.
367 if (destroy) {
368 component.destroy();
369 delete this.components[name];
370 // Remove attribute from DOM, if still present
371 if (this.hasAttribute(name)) {
372 window.HTMLElement.prototype.removeAttribute.call(this, name);
373 }
374 }
375
376 this.emit('componentremoved', component.evtDetail, false);
377 }
378
379 /**
380 * Initialize or update all components.

Callers 5

disconnectedCallbackMethod · 0.95
updateComponentMethod · 0.95
removeAttributeMethod · 0.95
mixinUpdateMethod · 0.95
a-entity.test.jsFile · 0.80

Calls 4

pauseMethod · 0.80
removeMethod · 0.80
destroyMethod · 0.80
emitMethod · 0.80

Tested by

no test coverage detected