Skip to content

attachToDocument deprecated and no documented substitute? #1584

Closed
@ghost

Description

Subject of the issue

attachToDocument was deprecated, in favor of attachTo, which is supposed to be more flexible, by allowing any css selector as the mount point.

But what is the actual replacement for attachToDocument: true? attachTo: document.documentElement yields HierarchyRequestError: The operation would yield an incorrect node tree.

Seems like the functionality of attachToDocument was deprecated in favor of something that does not substitute it, but only provides complementary behaviour.

Note that, besides the hierarchy problem, attachTo should be acompanied by wrapper.destroy() at the end. The thing is that this DESTROYS THE NODE to which the wrapper was attached. So, I can attach the element to the body, but the body is going to be destroyed in the call.

What I'm currently doing is adding a dumb routine to each test suite that needs the wrapper to be attached to the dom:


    var node = document.createElement("div");
    node.setAttribute('id', 'app')
    document.body.appendChild(node);

    const wrapper = mount(List, {
      attachTo: '#app'
    }

    ...

    wrapper.destroy() 

Needless to say, unless I'm missing something, it would be way easier to not have attachToDocument deprecated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions