Skip to content
This repository has been archived by the owner on Mar 2, 2021. It is now read-only.

DOM Refs #77

Open
ankoh opened this issue May 15, 2019 · 3 comments
Open

DOM Refs #77

ankoh opened this issue May 15, 2019 · 3 comments
Labels
enhancement New feature or request

Comments

@ankoh
Copy link

ankoh commented May 15, 2019

I really like Dodrios design but one thing is holding me back a bit.
There should be a way to get DOM refs.
In some situations you NEED to have the actual DOM nodes that have been derived from the virtual one.
One quite easy example is the HTMLCanvasElement.

From what I've seen this could probably be done quite elegantly within the change-list interpreter.
One could just tag specific vdom nodes and let the interpreter maintain the dom refs globally.
That would result in something similar to the ref of React.

I'm just leaving this here now to start the discussion.
Right now, I'm compensating the lack of DOM refs with a hacky pseudo CSS animation.
I could add that if my pet project stays alive and if this is in your interest.

@fitzgen
Copy link
Owner

fitzgen commented May 15, 2019

I think we want to move away from the change list stack machine approach because

  • I am fairly sure the opcode dispatch cost is higher than the Wasm->JS call overhead at this point
  • It makes it harder to do automatic event delegation

and also supporting these refs would be easier if dodrio held onto the dom elements from wasm.

That is to say, I agree this is a feature that Dodrio should support, but I think the right way to do it involves switching away from the change list stack machine approach.

@fitzgen fitzgen added the enhancement New feature or request label May 15, 2019
@dignifiedquire
Copy link

@fitzgen I have written a version that does away with the current approach to the change list, and directly calls into the various JS bindings.
The code lifes here: https://github.com/dignifiedquire/dodrio/tree/x-direct
So far performance seems at least similar, but it is hard to really measure, let me know if you are interested in a PR for this.

@extraymond
Copy link

@dignifiedquire Hi! Thanks for PR.

Mind if I ask if you are still pushing for this PR #146 ?

I have a project based on dodrio 0.2.0 and would really like to see how it works with the reworked change_list module. This PR would also make compilation easier since it won't require loading the change_list.js which made using dodrio inside web-worker hard. Thanks anyway.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants