-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Conversation
// 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'); |
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
updated |
Description:
With investigation help from @GavanWilhite.
initComponent
ininitComponentDependencies
was being called withundefined
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:
initComponent
for dependencies using data from the DOM (HTMLElement.prototype.getAttribute
).