choojs / nanomorph

🚅 - Hyper fast diffing algorithm for real DOM nodes
MIT License
726 stars 58 forks source link

Allow new tree to be DocumentFragment if `childrenOnly` #111

Closed goto-bus-stop closed 5 years ago

goto-bus-stop commented 5 years ago

Previously you could do

var children = [...]
var newCh = [...]
morph(html`<div>${children}</div>`, html`<section>${newCh}</section>`, { childrenOnly: true })

and the root <div> tag would be untouched, only the children arrays would be morphed.

With this PR, you can do the same for fragments

var children = [...]
var newCh = [...]
var frag = document.createDocumentFragment()
frag.append(...newCh)
morph(html`<div>${children}</div>`, frag, { childrenOnly: true })
yoshuawuyts commented 5 years ago

Is there a test we could add for this? This seems like the kind of thing that might be easy to regress. Also would help understand the change a bit better.

goto-bus-stop commented 5 years ago

yes good point :D

goto-bus-stop commented 5 years ago

merging since it's fairly small, i don't think it's controversial, and if it is nobody has raised objections anyway