Raynos / min-document

A minimal DOM implementation
MIT License
109 stars 27 forks source link

if appendChild is a fragment go wrong #33

Closed rachardking closed 8 years ago

yoshuawuyts commented 8 years ago

@rachardking could you provide some more details of what is going wrong? a code example would be nice - I can't quite make out what you mean

rachardking commented 8 years ago

i just read your source code ,like this

DOMElement.prototype.appendChild = function _Element_appendChild(child) {
    if (child.parentNode) {
        child.parentNode.removeChild(child)
    }

    this.childNodes.push(child)
    child.parentNode = this

    return child
}

and if the child is fragment This is incorrect HTML AST - document fragment can't be a child node of any other node

Raynos commented 8 years ago

This implementation is a simplication. I'm going to avoid adding complexity since the goal is to emulate a correct DOM; not catch all possible invalid states.