diff --git a/proposals/DOM-Parts-Imperative.md b/proposals/DOM-Parts-Imperative.md index 8034a6c9..9f996d75 100644 --- a/proposals/DOM-Parts-Imperative.md +++ b/proposals/DOM-Parts-Imperative.md @@ -24,8 +24,8 @@ interface AttributePart : Part { readonly attribute DOMString namespaceURI; }; -interface ChildNodePart : Part { - constructor(Node node, Node? previousSibling, Node? nextSibling); +interface ChildNodePart : NodePart { + constructor(Node parentNode, Node? previousSibling, Node? nextSibling); readonly attribute Node? previousSibling; readonly attribute Node? nextSibling; }; @@ -54,6 +54,10 @@ In the most basic level, this proposal consists of three DOM parts: [child](https://dom.spec.whatwg.org/#concept-tree-child) [nodes](https://dom.spec.whatwg.org/#concept-node) of a node which can be [replaced](https://dom.spec.whatwg.org/#concept-node-replace). + 1. Can represent the entire range within a parent node (when previousSibling + and nextSibling are missing), the range from a node to the end of an + element (when nextSibling is missing), or all nodes up to an element + (when previousSibling is missing). ### Basic Examples @@ -112,6 +116,16 @@ The resultant DOM will look like this: ``` +A `NodePart` can be used to add event listeners or other dynamically set attributes. + +```js +const link = staticContent.getElementById("link"); +const nodePart = new NodePart(link); +/// ... some code later +nodePart.node.addEventListener('click', () => {}); +nodePart.setAttribute('data-foo', someValue); +``` + ## Part Groups DOM parts need grouping and ownership to provide batching and to enable parts