- From: Robbie Speed <notifications@github.com>
- Date: Sun, 04 May 2025 13:31:09 -0700
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/issues/736/2849404655@github.com>
robbiespeed left a comment (whatwg/dom#736) I was originally pretty sceptical of the idea of a `FragmentElement` that appears as a true parent in the DOM tree `<fragment>contents</fragment>`, there are difficulties mentioned around this approach about how some elements have very restrictive constraints on child elements (ul, table, head, etc). This fragment element could be speced to allow placement anywhere, which is hard to polyfill. These difficulties are very similar to ones that would be present with a [html includes](https://github.com/whatwg/html/issues/2791) mechanism. I think there is a path that allows includes to be built off the foundation of a fragment element, and the end result could be very powerful. Ex: ```html <fragment src="/content.html"> <span class="spinner"></span> Loading... </fragment> ``` Fragments children would be replaced once loaded, and if src isn't provided then it is a simple way to group nodes without needing to special case CSS selectors with all the benefits discussed in this proposal. One added benefit of this approach is that event listeners can be attached to the fragment which would allow event delegation for it's children. `FragmentElement` should inherit from `Element` but not `HTMLElement`, HTML specific attributes like style and hidden don't apply to a fragment since they should be invisible to CSS and styling, and it would make it less awkward to use inside embedded svg and mathml. A wrapping element like this is also impossible to break, where as marker based fragments can be broken when a marker is moved away from it's partner (ex: extracting a range of content that starts in the middle of a fragment and ends outside). -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/dom/issues/736#issuecomment-2849404655 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/dom/issues/736/2849404655@github.com>
Received on Sunday, 4 May 2025 20:31:13 UTC