Skip to content
This repository has been archived by the owner on Jul 30, 2018. It is now read-only.

Make dom nodes created from v accessible in a widget #361

Closed
matt-gadd opened this issue Feb 16, 2017 · 8 comments
Closed

Make dom nodes created from v accessible in a widget #361

matt-gadd opened this issue Feb 16, 2017 · 8 comments

Comments

@matt-gadd
Copy link
Contributor

At the moment the only mechanism we have for accessing a dom node is via maquette's afterCreate and afterUpdate methods which are per v call which is a bit clunky. We perhaps should provide a a mechanism in WidgetBase that allows you to access all dom nodes in a widget by key, as well as a lifecycle function on WidgetBase where you know these will be available.

@matt-gadd matt-gadd changed the title Make domnodes for v accessible in a widget Make dom nodes for v accessible in a widget Feb 16, 2017
@matt-gadd matt-gadd changed the title Make dom nodes for v accessible in a widget Make dom nodes from v accessible in a widget Feb 16, 2017
@matt-gadd matt-gadd changed the title Make dom nodes from v accessible in a widget Make dom nodes created from v accessible in a widget Feb 16, 2017
@edhager edhager self-assigned this Feb 16, 2017
@edhager
Copy link
Contributor

edhager commented Feb 17, 2017

I did some prototyping and came up with one possible solution: edhager@2d24075

It uses the render decorator mechanism in WidgetBase.

@edhager
Copy link
Contributor

edhager commented Feb 22, 2017

I started updating WidgetBase with code based on what was done in the prototype. My progress is in https://github.com/edhager/widget-core/tree/widgetbase-node-lifecycle.

I have not written any tests yet. At this point, all I know is my code compiles.

@dylans dylans added this to the 2017.02 milestone Feb 22, 2017
@edhager
Copy link
Contributor

edhager commented Feb 23, 2017

I added some tests and fixed some bugs. Getting close. I am not sure how to write a test for the afterCreate calls.

@bitpshr
Copy link
Member

bitpshr commented Feb 23, 2017

Not sure how relevant my approach is for your work, but when testing widget afterCreate calls, I pass in an object cast to any instead of an event, and verify certain properties or functions are called on that object.

@edhager
Copy link
Contributor

edhager commented Feb 23, 2017

I just added some update tests and there is a problem with my code. The way I am adding the afterCreate and afterUpdate callbacks in a render decorator is giving me this error:

Error: Functions may not be updated on subsequent renders (property: afterCreate). Hint: declare event handler functions outside the render() function.

I may have to rethink my approach.

@edhager
Copy link
Contributor

edhager commented Feb 24, 2017

I fixed the problem with the way I was registering the afterCreate and afterUpdate callbacks. A vdom update now works. I think I have everything working now.

https://github.com/edhager/widget-core/tree/widgetbase-node-lifecycle

@edhager
Copy link
Contributor

edhager commented Feb 24, 2017

I think my code may still have an issue. I am storing existing afterCreate and afterUpdate callbacks in maps using properties.key as the key to the map. That is not good enough because I think keys can be reused in different child lists.

@edhager
Copy link
Contributor

edhager commented Feb 24, 2017

I fixed the duplicate key issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants