-
-
Notifications
You must be signed in to change notification settings - Fork 10
Closes #9 #10
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
Closed
Closed
Closes #9 #10
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ea7f88f
move needsIndex to seprate file
peterbabic 50ae64e
remove ciruclar dependency passing any via state
peterbabic 2e09516
move needsIndex to any
peterbabic 0f99c5d
make needsIndex private
peterbabic 77431f0
make needsIndex private
peterbabic edf20d2
Update index.js
wooorm 89f8735
move needsIndex into local scope
peterbabic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -3,7 +3,6 @@ | |||||
module.exports = match | ||||||
|
||||||
var zwitch = require('zwitch') | ||||||
var pseudo = require('./pseudo') | ||||||
var test = require('./test') | ||||||
var nest = require('./nest') | ||||||
|
||||||
|
@@ -52,7 +51,8 @@ function rule(query, tree, state) { | |||||
scopeNodes: tree.type === 'root' ? tree.children : [tree], | ||||||
iterator: iterator, | ||||||
one: state.one, | ||||||
shallow: state.shallow | ||||||
shallow: state.shallow, | ||||||
any: state.any | ||||||
}) | ||||||
) | ||||||
|
||||||
|
@@ -71,11 +71,23 @@ function rule(query, tree, state) { | |||||
} | ||||||
|
||||||
function configure(query, state) { | ||||||
var needsIndex = [ | ||||||
'first-child', | ||||||
'first-of-type', | ||||||
'last-child', | ||||||
'last-of-type', | ||||||
'nth-child', | ||||||
'nth-last-child', | ||||||
'nth-of-type', | ||||||
'nth-last-of-type', | ||||||
'only-child', | ||||||
'only-of-type' | ||||||
] | ||||||
var pseudos = query.pseudos || [] | ||||||
var index = -1 | ||||||
|
||||||
while (++index < pseudos.length) { | ||||||
if (pseudo.needsIndex.indexOf(pseudos[index].name) > -1) { | ||||||
if (needsIndex.indexOf(pseudos[index].name) > -1) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
this change can be reverted |
||||||
state.index = true | ||||||
break | ||||||
} | ||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,23 +5,9 @@ module.exports = match | |
var zwitch = require('zwitch') | ||
var not = require('not') | ||
var convert = require('unist-util-is/convert') | ||
var anything = require('./any') | ||
|
||
var is = convert() | ||
|
||
match.needsIndex = [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this change can be reverted |
||
'first-child', | ||
'first-of-type', | ||
'last-child', | ||
'last-of-type', | ||
'nth-child', | ||
'nth-last-child', | ||
'nth-of-type', | ||
'nth-last-of-type', | ||
'only-child', | ||
'only-of-type' | ||
] | ||
|
||
var handle = zwitch('name', { | ||
unknown: unknownPseudo, | ||
invalid: invalidPseudo, | ||
|
@@ -61,6 +47,7 @@ function match(query, node, index, parent, state) { | |
function matches(query, node, index, parent, state) { | ||
var shallow = state.shallow | ||
var one = state.one | ||
var anything = state.any | ||
var result | ||
|
||
state.one = true | ||
|
@@ -160,6 +147,7 @@ function hasSelector(query, node, index, parent, state) { | |
var one = state.one | ||
var scopeNodes = state.scopeNodes | ||
var value = appendScope(query.value) | ||
var anything = state.any | ||
var result | ||
|
||
state.shallow = false | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change can be reverted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am getting quite lost here :sad:
What could be reverted, please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We were discussing two approaches.
needsIndex
inany
, remove it frompseudo
, which doesn’t work.any
downAs 1 didn’t work, it can be reverted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pardon me, but I am not seeing why it doesn't work. Could you please point me to the right direction?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You said here in the issue that changing
needsIndex
had no effectUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have made another commit 89f8735 which I believe places
needsIndex
into even better place, by still not tripping any tests and with the circular dependency resolved.If there is need to revert something, it has to be by your reasoning as a reviewer, otherwise I suspect I wasn't clear somewhere in the issue and your interpretation of what I have stated is different from what I have meant.
Please, provide way of moving this PR further, discarding the "this change could be reverted" suggestions in the process, if possible.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I might start getting what do you mean. To make things clear further, BOTH "approaches" need to be applied, not just the second one (with reverting the first one) to remove the cyclic dependency.
It is true that I said the first one does not work, meaning it reduced the dependency from direct (A -> B -> A) to indirect (A -> B -> C -> A, indirect cyclic dependencies tend to be easier to resolve) which was then resolved by the approach 2.