Skip to content

isValidNode function seems redundant #56

@anewusr

Description

@anewusr

processingInstructions already ignores any node that fails all shouldProcessNode; it seems both confusing and unnecessary to have that extra guard.

Below is the code that I take issue with:

if (isValidNode(node)) { // how is this helpful?
     var processingInstruction = find(function (processingInstruction) {
       return processingInstruction.shouldProcessNode(node);
     }, processingInstructions);
     if (processingInstruction != null) {
       var children = reject(function (x) {return x == null || x === false;},
         addIndex(map)(function (child, i) {
           return traverseDom(child, isValidNode, processingInstructions, i);
         }, node.children || []));

       if (processingInstruction.replaceChildren) {
         return utils.createElement(node, index, node.data, [
           processingInstruction.processNode(node, children, index),
         ]);
       }

       return processingInstruction.processNode(node, children, index);
     } else {
       return false;
     }
   } else {
     return false;
   }

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