- From: Benjamin Aster <notifications@github.com>
- Date: Tue, 01 Aug 2023 06:08:15 -0700
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/issues/1217/1660277704@github.com>
Basically, all I *really* need is three things: - convert an HTML/XML string to some magical tree of node objects (aka. Document) or create a new one - mess around with that tree by adding, modifying and removing nodes - convert the tree back to a valid HTML/XML string I don't really need anything like event listeners or even being able to postMessage the tree to the main thread. I'm ok with the idea of a "lite" "DOM alternative"; I think that would reduce down to something like the following API shape (names TBD of course): - `LiteNode`: - `.childNodes` - `.firstChild` (?) - `.lastChild` (?) - `.nextSibling` - `.nodeName` - `.parentElement` - `.parentNode` - `.previousSibling` - `.textContent` - `.cloneNode()` - `.compareDocumentPosition()` (?) - `.contains()` - `.getRootNode()` (?) - `.isEqualNode()` (?) - `.normalize()` - `LiteElement` (extends `LiteNode`): - `.classList` (?) (for convenience) - `.dataset` (?) (for convenience) - `.innerHTML` (?) - `.innerText` (?) (always treats element like `white-space: normal`) - `.localName` - `.namespaceURI` - `.nextElementSibling` - `.outerHTML` (?) - `.prefix` - `.previousElementSibling` - `.tagName` - `.after()` (?) - `.append()` (?) - `.before()` (?) - `.getAttribute()` - `.getAttributeNS()` - `.getAttributeNames()` - `.hasAttribute()` - `.hasAttributeNS()` - `.insertAdjacentElement()` (?) - `.insertAdjacentHTML()` (?) - `.insertAdjacentText()` (?) - `.prepend()` (?) - `.remove()` - `.removeAttribute()` - `.removeAttributeNS()` - `.replaceChildren()` - `.replaceWith()` - `.toggleAttribute()` - `LiteElement` & `LiteDocument` (both extend `LiteNode`): - `.childElementCount` - `.children` - `.firstElementChild` (?) - `.lastElementChild` (?) - `.getElementsByClassName()` - `.getElementsByTagName()` - `.getElementsByTagNameNS()` - `LiteDocument` (extends `LiteNode`): - `.body` (?) - `.documentElement` - `.head` (?) - `.getElementById()` - `LiteDocumentFragment` (extends `LiteNode`) - equivalent of `DOMParser` - equivalent of `XMLSerializer` - equivalent of `window.document.implementation.createDocument()` - equivalent of `window.document.implementation.createDocumentType()` - equivalent of `window.document.implementation.createHTMLDocument()` - equivalent of `window.document.createAttribute()` - equivalent of `window.document.createAttributeNS()` - equivalent of `window.document.createCDATASection()` - equivalent of `window.document.createComment()` - equivalent of `window.document.createElement()` - equivalent of `window.document.createElementNS()` (?) - equivalent of `window.document.createProcessingInstruction()` - equivalent of `window.document.createTextNode()` Some things to consider: - Shadow roots? (probably out of scope) - [Sanitizer API](https://wicg.github.io/sanitizer-api/)? - CSS selector parser? - `.closest()` (?) - `.matches()` (?) - `.querySelector(All)()` (?) (would be **very** helpful!) - `.before()`/`.after()`/`.prepend()`/`.append()` vs `.insertAdjacentElement()`/`.insertAdjacentText()`? (only one of them is needed) - Non-element nodes (text nodes, comments, CDATA sections and XML processing instructions): Should they just use the `LiteNode` interface directly or get their own respective interfaces like in "main" DOM? - XPath? - XSLT? -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/dom/issues/1217#issuecomment-1660277704 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/dom/issues/1217/1660277704@github.com>
Received on Tuesday, 1 August 2023 13:08:20 UTC