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

Method setupMutationObserver

src/core/a-node.js:163–178  ·  view source on GitHub ↗

* With custom elements V1 attributeChangedCallback only fires * for attributes defined statically via observedAttributes. * One can assign any arbitrary components to an A-Frame entity * hence we can't know the list of attributes beforehand. * This function setup a mutation observer to k

()

Source from the content-addressed store, hash-verified

161 * in the DOM and update components accordingly.
162 */
163 setupMutationObserver () {
164 var self = this;
165 var observerConfig = {attributes: true, attributeOldValue: true};
166 var observer = new MutationObserver(function callAttributeChangedCallback (mutationList) {
167 var i;
168 for (i = 0; i < mutationList.length; i++) {
169 if (mutationList[i].type === 'attributes') {
170 var attributeName = mutationList[i].attributeName;
171 var newValue = window.HTMLElement.prototype.getAttribute.call(self, attributeName);
172 var oldValue = mutationList[i].oldValue;
173 self.attributeChangedCallback(attributeName, oldValue, newValue);
174 }
175 }
176 });
177 observer.observe(this, observerConfig);
178 }
179
180 getChildren () {
181 return Array.prototype.slice.call(this.children, 0);

Callers 1

loadMethod · 0.80

Calls 1

Tested by

no test coverage detected