Skip to content

Conversation

@ngokevin
Copy link
Member

@ngokevin ngokevin commented Apr 4, 2016

Description: Mapped attributes were overwriting defined components.

Changes proposed:

  • Don't keep track of internal component data. Just do non-destructive updates when possible with setAttribute(component, propName, propValue) syntax.
  • Move default component initialization to separate method.
  • Support merging data with default components + defined components.

self.setAttribute(componentName, propName, componentData[propName]);
});
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps we should return only if self.setAttribute(…) actually got called?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm only returning here to mimic an if/else. Not a big fan of that style since it's less clear on the intent, but dmarcos likes that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, I guess I understand

applyDefaultComponents: {
value: function () {
var self = this;
var defaultData = utils.extendDeep(this.defaultAttributes);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really necessary to create a local copy of the object?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah. if you modify this object, it will affect all other entities created from this prototype.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see where is the defaultData object modified.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I think since I removed keeping track of component data, this is no longer needed. Good catch.

@dmarcos dmarcos merged commit 083ace2 into aframevr:master Apr 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants