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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get nanocomponent instance reference from root node? #81

Open
YerkoPalma opened this issue Apr 24, 2018 · 3 comments
Open

How to get nanocomponent instance reference from root node? #81

YerkoPalma opened this issue Apr 24, 2018 · 3 comments

Comments

@YerkoPalma
Copy link
Member

Hi 馃憢

I have a situation where I have many components and some external libraries which manipulates the DOM. So, those libraries transform the root node of my components, and I need to run functions from the components after they are manipulated but I can't figure out how to get reference to that instance from the node manipulated for this library.

In other words, what I would like is the inverse of the element property of nanocomponent, perhaps a function that given a DOM element returns the actual nanocomponent tied to it. Is this possible?

Thanks :)

@yoshuawuyts
Copy link
Member

perhaps a function that given a DOM element returns the actual nanocomponent tied to it

Not at the moment, no. Appending properties to prototypes on the fly greatly reduces performance, so maybe that's not the solution. Perhaps you could share a cache instance around, and read the key from the DOM element to find the right instance?

@YerkoPalma
Copy link
Member Author

I wasn't suggesting to change prototype on the fly, because I had no idea how to achieve what I was asking for :)

Now I think I will keep a global object referencing the components I need.
Thanks for the feedback 鉁岋笍

@bcomnes
Copy link
Contributor

bcomnes commented Apr 24, 2018

DOM Nodes created by nanocomponent shouldn't be externally modified (given the way thing work now). If you must, pass the data changes into the component through render or add additional class methods and handle the internal mutation at the component level.

If you see something nanocomponent can do internally to be more accommodating I'm open to ideas.

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

No branches or pull requests

3 participants