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

Method updateComponent

src/core/a-entity.js:443–459  ·  view source on GitHub ↗

* Initialize, update, or remove a single component. * * When initializing, we set the component on `this.components`. * * @param {string} attr - Component name. * @param {object} attrValue - Value of the DOM attribute. * @param {boolean} clobber - If new attrValue completely replac

(attr, attrValue, clobber)

Source from the content-addressed store, hash-verified

441 * @param {boolean} clobber - If new attrValue completely replaces previous properties.
442 */
443 updateComponent (attr, attrValue, clobber) {
444 var component = this.components[attr];
445
446 if (component) {
447 // Remove component.
448 if (attrValue === null && !checkComponentDefined(this, attr)) {
449 this.removeComponent(attr, true);
450 return;
451 }
452 // Component already initialized. Update component.
453 component.updateProperties(attrValue, clobber);
454 return;
455 }
456
457 // Component not yet initialized. Initialize component.
458 this.initComponent(attr, attrValue, false);
459 }
460
461 /**
462 * If `attr` is a component name, detach the component from the entity.

Callers 4

updateComponentsMethod · 0.95
setEntityAttributeMethod · 0.95
setAttributeMethod · 0.95
a-entity.test.jsFile · 0.45

Calls 3

removeComponentMethod · 0.95
initComponentMethod · 0.95
checkComponentDefinedFunction · 0.85

Tested by

no test coverage detected