IssueRaiser

Proposal: a DocumentFragment whose nodes do not get removed once inserted

**edit** I wouldn't mind `Node.DOCUMENT_PERSISTENT_FRAGMENT_NODE` name/kind neither ### TL;DR The document fragment is a great primitive to wrap together numerous nodes and append these directly as batch, however a fragment loses all its children as soon as appended, making it's one-off usage limited in those cases where a list of nodes, at a certain position, is meant. This proposal would like to explore the possibility of a live document fragment that: * does not lose its childNodes once appended * it's still transparent / unaddressable from CSS * it's also transparent for any other node so that it's still possible, as example, to append many `<TD>` or `<TR>` through such fragment, and keep a reference for future updates ## Why Both virtual DOM based libraries, such React, as well as direct DOM based one, such as hyperHTML, or lit-html, have been implementing their own version of a persistent fragment in a way or another. If there was a primitive to directly reference more than a node, through a fragment with a well known position on the DOM, I am pretty sure all libraries would eventually move to adopt such primitive, so that a tag function could handle both `<p>1</p>` and `<p>1</p><p>2</p>` without needing to re-invent a similar wheel every single time, and making portability between libraries and frameworks easier than ever: it's just a DOM node! ## Example ```js // either persistent or live const pf = document.createLiveFragment(); // append zero, one, or a

Posted by WebReflection on Mar 6, 2019, 7:28 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.4,000 issues0 comments

github (Other)

Proposal: a DocumentFragment whose nodes do not get removed once inserted

WebReflectionMar 6, 2019, 7:28 PM

**edit** I wouldn't mind `Node.DOCUMENT_PERSISTENT_FRAGMENT_NODE` name/kind neither ### TL;DR The document fragment is a great primitive to wrap together numerous nodes and append these directly as batch, however a fragment loses all its children as soon as appended, making it's one-off usage limited in those cases where a list of nodes, at a certain position, is meant. This proposal would like to explore the possibility of a live document fragment that: * does not lose its childNodes once appended * it's still transparent / unaddressable from CSS * it's also transparent for any other node so that it's still possible, as example, to append many `<TD>` or `<TR>` through such fragment, and keep a reference for future updates ## Why Both virtual DOM based libraries, such React, as well as direct DOM based one, such as hyperHTML, or lit-html, have been implementing their own version of a persistent fragment in a way or another. If there was a primitive to directly reference more than a node, through a fragment with a well known position on the DOM, I am pretty sure all libraries would eventually move to adopt such primitive, so that a tag function could handle both `<p>1</p>` and `<p>1</p><p>2</p>` without needing to re-invent a similar wheel every single time, and making portability between libraries and frameworks easier than ever: it's just a DOM node! ## Example ```js // either persistent or live const pf = document.createLiveFragment(); // append zero, one, or a

Comments (0)

No comments yet. Start the discussion.

Comment on this issue