Skip to content

Exposing parentElement on treeAdapter.createElement  #285

@pmdartus

Description

@pmdartus

While implementing support for custom elements in JSDOM, I am facing the following limitation. The create an element for a token algorithm use the intended parent to retrieve the associated document for a newly created node.

In it's current implementation the JSDOM treeAdapter shares the same document for all the created node. However this approach doesn't work in the context of template element, since the HTMLTemplateElment content is associated with an inert template document.

What do you think about extended the current createElement signature to pass the intededParent as parameter?

// The intendedParent can be undefined when this hook is invoked for the root html element.
createElement(tagName: string, namespaceURI: string, attrs: Attribute[], intendedParent?: Element): Element;

An alternative viable approach would be to expose in some way the current element stack.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions