Skip to content

morphAttrs should handle only elements #254

@mihaiav

Description

@mihaiav

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;
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions