Due to templateContent() returning a DocumentFragment and morphdom not working right with a DocumentFragment. It replaces instead of diffing and morphing like it should.
How?
Pass in a ternary for the new element that if childrenOnly is true passes this.templateContent, else passes this.templateElement.innerHTML. This keeps childrenOnly working as it has no problem with a DocumentFragment but does not work with this.templateElement.innerHTML. And for regular morphs they diff and morph correctly with this.templateElement.innerHTML where templateElement() gets the the template element and innerHTML for the html.
What?
morph() replaces instead of morphs.
Why?
Due to templateContent() returning a DocumentFragment and morphdom not working right with a DocumentFragment. It replaces instead of diffing and morphing like it should.
How?
Pass in a ternary for the new element that if childrenOnly is true passes
this.templateContent
, else passesthis.templateElement.innerHTML
. This keeps childrenOnly working as it has no problem with a DocumentFragment but does not work withthis.templateElement.innerHTML
. And for regular morphs they diff and morph correctly withthis.templateElement.innerHTML
where templateElement() gets the the template element and innerHTML for the html.This had come up in the CableReady repo: #58 #67