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 component dependencies being initialized with no data (fixes #2033, #1841, #1848) #2036

Merged
merged 2 commits into from
Nov 3, 2016

Conversation

ngokevin
Copy link
Member

@ngokevin ngokevin commented Nov 1, 2016

Description:

With investigation help from @GavanWilhite.

initComponent in initComponentDependencies was being called with undefined rather than reading data from the DOM. The component later initializes with a null data set because components themselves never fetch data from the DOM; they depend on the entity to pass data to them.

Changes proposed:

  • Call initComponent for dependencies using data from the DOM (HTMLElement.prototype.getAttribute).
  • Increase confidence of dependency system with tests.
  • Specific tests for cursor + raycaster combo.

// On debug mode we write the component state to the DOM attributes

// On debug mode we write the component state to the DOM attributes.
isDebugMode = this.sceneEl && this.sceneEl.getAttribute('debug');
Copy link
Member

Choose a reason for hiding this comment

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

I would leave the variables at top. If you want to reuse the same variable somewhere else in the function you have to remember to move it to the top or at least above the other place you want to use it.

// Call getAttribute to initialize the data from the DOM.
self.initComponent(
componentName,
HTMLElement.prototype.getAttribute.call(self, componentName),
Copy link
Member

Choose a reason for hiding this comment

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

If the dependency is not defined in the entity this will pass a null to the initComponet function. What are the consequences?

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 guess I should do || undefined and add a test case.

Copy link
Member

Choose a reason for hiding this comment

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

At some point (I cannot longer tell you if the case) a null value was interpreted as a component being removed. This is why undefined value was passed before.

@ngokevin
Copy link
Member Author

ngokevin commented Nov 1, 2016

updated

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.

2 participants