Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix registerPrimitive property merging (fixes #1324) #1332

Merged
merged 1 commit into from
Apr 4, 2016

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants