From 6f80febd7d4dd3b8dcd6fa3ef8efbad5e850d988 Mon Sep 17 00:00:00 2001 From: jquense Date: Sat, 10 Oct 2015 10:55:22 -0400 Subject: [PATCH] [fixed] :dom and :composite selectors --- src/element-selector.js | 4 ++-- src/instance-selector.js | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/element-selector.js b/src/element-selector.js index 56a1c8f..024e13f 100644 --- a/src/element-selector.js +++ b/src/element-selector.js @@ -13,8 +13,8 @@ compiler.registerPseudo('has', function(compiledSelector) { } }) -compiler.registerPseudo('dom', isDomElement) -compiler.registerPseudo('composite', isCompositeElement) +compiler.registerPseudo('dom', ()=> isDomElement) +compiler.registerPseudo('composite', ()=> isCompositeElement) compiler.registerNesting('any', test => anyParent.bind(null, test)) diff --git a/src/instance-selector.js b/src/instance-selector.js index 3eebf04..4ce5ed1 100644 --- a/src/instance-selector.js +++ b/src/instance-selector.js @@ -20,8 +20,8 @@ compiler.registerPseudo('has', function(compiledSelector) { } }) -compiler.registerPseudo('dom', isDomElement) -compiler.registerPseudo('composite', isCompositeElement) +compiler.registerPseudo('dom', ()=> isDomElement) +compiler.registerPseudo('composite', ()=> isCompositeElement) compiler.registerNesting('any', test => (element, inst, parent) => anyParent(test, element, parent)) @@ -30,7 +30,7 @@ compiler.registerNesting('>', test => (element, inst, parent) => directParent(test, element, parent)) -function findAll(inst, test, getParent = ()=> ({ parent: null }), excludeSelf = true) { +function findAll(inst, test, excludeSelf = true, getParent = ()=> ({ parent: null })) { let found = []; if (!inst || !inst.getPublicInstance) @@ -48,13 +48,13 @@ function findAll(inst, test, getParent = ()=> ({ parent: null }), excludeSelf = Object.keys(renderedChildren).forEach(key => { found = found.concat( - findAll(renderedChildren[key], test, parent, false) + findAll(renderedChildren[key], test, false, parent) ); }) } else if (isCompositeComponent(publicInst)) { found = found.concat( - findAll(inst._renderedComponent, test, parent, false) + findAll(inst._renderedComponent, test, false, parent) ); } @@ -72,7 +72,7 @@ export function match(selector, inst, includeSelf = true) { ? inst._reactInternalComponent : ReactInstanceMap.get(inst) - return findAll(tree, compiler.compile(selector), undefined, !includeSelf) + return findAll(tree, compiler.compile(selector), !includeSelf) } export let { compile, compileRule, selector } = compiler