Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

morphAttrs should handle only elements #254

Open
mihaiav opened this issue Apr 30, 2024 · 0 comments
Open

morphAttrs should handle only elements #254

mihaiav opened this issue Apr 30, 2024 · 0 comments

Comments

@mihaiav
Copy link

mihaiav commented Apr 30, 2024

morphAttrs is throwing exception on various element types.For example if the nodeType is of DOCUMENT_TYPE_NODE (10). I think the same happens on other node types that don't have attributes.
I think this line
https://github.com/patrick-steele-idem/morphdom/blob/master/src/morphAttrs.js#L12

    if (toNode.nodeType === DOCUMENT_FRAGMENT_NODE || fromNode.nodeType === DOCUMENT_FRAGMENT_NODE) {
      return;
    }

should be changed to

        // document-fragments dont have attributes so lets not do anything
        var hasAttributes = (toNode.nodeType === ELEMENT_NODE || toNode.nodeType === ATTRIBUTE_NODE) &&
        (fromNode.nodeType === ELEMENT_NODE || fromNode.nodeType === ATTRIBUTE_NODE);
        if (!hasAttributes) {
            return;
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant