-
-
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
Closes #9 #10
Conversation
Tries to remove cyclical dependency any.js -> psudo.js addressing [syntax-tree#9](syntax-tree#9)
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.
thanks for taking a stab at this!
Co-authored-by: Titus <tituswormer@gmail.com>
Co-authored-by: Titus <tituswormer@gmail.com>
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.
The recursiveness seems to only be needed in matches
(x:matches(:link)
) and hasSelector
(x:has(:link)
). I’m assuming those two aren’t tested with pseudos in the select
or selectAll
cases
|
||
var is = convert() | ||
|
||
match.needsIndex = [ |
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
@@ -75,7 +88,7 @@ function configure(query, state) { | |||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
if (needsIndex.indexOf(pseudos[index].name) > -1) { | |
if (pseudo.needsIndex.indexOf(pseudos[index].name) > -1) { |
this change can be reverted
var zwitch = require('zwitch') | ||
var pseudo = require('./pseudo') |
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.
- place
needsIndex
inany
, remove it frompseudo
, which doesn’t work. - Pass
any
down
As 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 effect
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.
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.
lib/any.js
Outdated
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' | ||
] | ||
|
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.
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' | |
] |
this change can be reverted
Configure function is the sole consumer of the needsIndex array, it shoould then be in it's local scope. This change further improves code quiality.
I don’t see why the changes previously applied for approach 1 are needed. Moving Could you make the changes in this PR as small as possible? Only the change that And could you pass |
By passing any down to all files, that is removed though? |
Hold on, let me try and do it myself. I’m sorry that I can’t seem to make my suggestion clear. |
I am sorry, you are right. Just by applying the approach 2 the cyclic dependency is resolved. However by passing |
I described |
Well, to my best efforts:
These two could be squashed if needed, but TBH I am not quite there yet about the #10 (comment) |
I’m already working on that approach, thanks, will push soon (but install graphviz for marge broke my computer 🥺) |
This PR fixes #9
It is not a bug fix, but rather a code quality improvement. It's purpose is to stop JS bundler complaining about the detected circular dependency.
It does not include any new tests, because it would require testing for circular dependency, not sure what the right approach would be right now. The issue thread shows dependency graphs and a clear resolve of the cyclic dependency that existed before PR.
Note that possible state (context) pollution introduced by passing
any
down the road from theindex.js