Skip to content

Commit

Permalink
[fixed] :dom and :composite selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
jquense committed Oct 10, 2015
1 parent 7e88563 commit 6f80feb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/element-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
12 changes: 6 additions & 6 deletions src/instance-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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)
Expand All @@ -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)
);
}

Expand All @@ -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

0 comments on commit 6f80feb

Please sign in to comment.