V7 and Document Fragments
See original GitHub issueI really love new simplified patch
usage and the simplified algorithm.
However, it seems we assume that the node.parentNode
always exists in https://github.com/jorgebucaran/superfine/blob/master/src/index.js#L265
This works for the most part, but fails when the provided node is a DocumentFragment, since DocumentFragment won’t have a parentNode
.
The patch
in this case errors out with:
To add more context, I have a web-components wrapper based on Superfine
, which was invoking the patch
in v6 as https://github.com/osdevisnot/supertag/blob/master/src/supertag.ts#L94
With V7, I believe the correct usage would simply be something like:
this[ROOT] = patch(this[ROOT], this.render());
But this fails with above error since this[ROOT]
is a DocumentFragment created using
this[ROOT] = this.attachShadow({ mode: 'open' });
Any pointers on how we can use the V7 patch with DocumentFragments? Or am I missing something?
Issue Analytics
- State:
- Created 4 years ago
- Comments:20 (13 by maintainers)
Thank you both! I’ll check this out asap (possibly over the weekend).
@stken2050 You could use
document.body
and produce a<body>
with your vdom too. The change that you probably missed is that we replace (recycling if possible) your DOM node now, rather than append to it.Will do. 👍