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

isValidNode function seems redundant #56

Open
anewusr opened this issue Oct 15, 2017 · 1 comment
Open

isValidNode function seems redundant #56

anewusr opened this issue Oct 15, 2017 · 1 comment

Comments

@anewusr
Copy link

anewusr commented Oct 15, 2017

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;
   }
@connorjclark
Copy link

I agree. If there is a use case for this, can it be displayed in the README?

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

2 participants