- From: Shiba <notifications@github.com>
- Date: Sat, 16 Nov 2024 01:34:26 -0800
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/issues/736/2480494020@github.com>
Your polyfill won't work with empty fragments: ```js const fragment = new PersistentFragment(); const textA = document.createTextNode('a'); const textB = document.createTextNode('b'); document.body.append(document.createElement('hr'), fragment); fragment.append(textA) document.body.append(document.createElement('hr')); fragment.append(textB) ``` Even loses where it's as soon as it has no child: ```js const textA = document.createTextNode('a'); const textB = document.createTextNode('b'); const fragment = new PersistentFragment(textA); document.body.append(document.createElement('hr'), fragment); textA.remove() fragment.append(textB) document.body.append(document.createElement('hr')); ``` Still requires some node in it to follow itself in the DOM: ```js const fragment = new PersistentFragment(document.createComment('')); const textA = document.createTextNode('a'); const textB = document.createTextNode('b'); document.body.append(document.createElement('hr'), fragment); fragment.append(textA) document.body.append(document.createElement('hr')); fragment.append(textB) ``` Empty fragments are important for conditional rendering with signals. That's why comment nodes are the work around atm. They let frameworks to follow empty fragments. If we have to wrap conditional with something else, what is the point of having a fragment in the first place? This is less flexible than using comment nodes with some abstraction around it, which was a workaround anyway. If an author or framework is using persistent fragments they expect it anyway. At this point why complicate things while we can just have normal parent child relationship of nodes? When I insert a fragment inside a `ParentNode`, I expect to access it via `childNodes`. Normal parent child relationship. Similar to how I expect to see an item in an array when i push it in. I should be able to freely mutate and move the fragment, for example in devtools or with js? And nothing should break. <details> <summary> And while there; </summary> Why not just let authors follow lifecycle of not just custom elements, but any element they want as well as fragment. So frameworks doesn't break when you touch DOM with js or devtools. </details> -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/dom/issues/736#issuecomment-2480494020 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/dom/issues/736/2480494020@github.com>
Received on Saturday, 16 November 2024 09:34:30 UTC