question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Snabbdom patches over given container

See original GitHub issue

While I’ve been writing my intergration for snabbdom with Cycle.js, I’ve come to notice that running for example patch(document.querySelector('.app'), view), snabbdom is actually patching over .app. However my needs are for the view to be appended to .app, because I need to listen to events relative to .app. Is there a way to do this currently or is it possible to add support for this? I’d be happy to submit a PR if it is needed and would be accepted.

Thank you for your time.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:48 (29 by maintainers)

github_iconTop GitHub Comments

1reaction
leeoniyacommented, Mar 11, 2016

@paldepind if you split the vtree-build/diff and DOM-hydration stages, it becomes trivial to hydrate the vtree from a server-built DOM without any diffing (assuming it was built from the identical vtree). in domvm, the entire loop is a few recursive lines: https://github.com/leeoniya/domvm/blob/master/src/view.js#L309-L318

1reaction
paldepindcommented, Mar 11, 2016

@avesus In principle you can do that. That is what virtual-dom does. But diffing just a real DOM tree against a virtual one is not as fast as diffing two virtual trees against each other. Thus that is what Snabbdom does. In your case it would have been nice if Snabbdom could patch DOM against VDOM. But it would be a lot of extra code. I think the workaround is acceptable. You only have to do it once.

Read more comments on GitHub >

github_iconTop Results From Across the Web

snabbdom/snabbdom - Gitter
Question—is there a way to prevent snabbdom patch from overwriting an element? For example, given <div id="container"><div id="one">one</div><div ...
Read more >
Snabbdom Renderer - ServiceNow Developers
Patches an empty vnode to the element so we run hooks and cleanup ... This hook is invoked on a virtual node when...
Read more >
tea-snabbdom / ento / Observable
patch = RuntimeError: Failed to fetch dynamically imported module: https://unpkg.com/snabbdom@1.0.1/build/package/modules/attributes.js.
Read more >
Using Proxy and Virtual DOM to Build Your Own Framework
Also, upon inspecting each rendering, the child HTML of the container is replaced ... var patch = snabbdom.init([ // Init patch function with...
Read more >
snabbdom.scala
Virtual DOM for Scala.js based on Snabbdom.js ... "Please enter a value: ", input( size := 3, onChange := foo ) ) //...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found