- From: Andrea Giammarchi <notifications@github.com>
- Date: Thu, 14 Nov 2024 05:36:13 -0800
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Thursday, 14 November 2024 13:36:16 UTC
@thoughtsunificator that would still require an explicit "*PersistentFragment*" definition because somebody could reuse a document fragment to append or move other nodes later on.
In that regard, having a `DocumentFragment` extend that accepts a list of nodes and consider those immutable in terms of ownership, might also work so that if you append that fragment elsewhere its known nodes would follow.
For runtime/dynamic sake though, that fragment should be able to perform regular operations and update such internal list of nodes without needing to remove these from the living DOM.
**example**
```js
const a = document.createTextNode('a');
const c = document.createTextNode('c');
const fragment = new PersistentFragment(a, c);
fragment.ownChildNodes; // [a, c]
document.body.append(fragment); // ac
fragment.insertBefore(document.createTextNode('b'), c);
fragment.ownChildNodes; // [a, b, c]
document.body.append(fragment); // abc
```
--
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/736#issuecomment-2476374536
You are receiving this because you are subscribed to this thread.
Message ID: <whatwg/dom/issues/736/2476374536@github.com>
Received on Thursday, 14 November 2024 13:36:16 UTC