WICG / webcomponents

Web Components specifications
Other
4.34k stars 371 forks source link

[dom-parts] cloneWithParts / cloneTree #1012

Open rniwa opened 1 year ago

rniwa commented 1 year ago

We need an API to clone parts with tree.

Current proposal: https://github.com/WICG/webcomponents/blob/gh-pages/proposals/DOM-Parts.md#cloning-parts

partial interface Node {
    NodeWithParts cloneTree(optional CloneOptions options = {});
};

dictionary CloneOptions {
    boolean deep = true;
    Document? document;
    PartGroup? partGroup;
};

dictionary NodeWithParts {
    Node node;
    PartGroup? partGroup;
};

What happens to the current values of DOM parts? Do we allow DOM parts to have some non-initial values and do we clone those values as well? If so, what do we do with PropertyPart / CustomPart?

tbondwilkinson commented 1 year ago

I would expect parts to be deep cloned just like elements. If an attribute part reset back to empty string, but the DOM is showing some value for that attribute, that would be strange