-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add allowRoot property to nodes that can be returned by a function in…
…to root or ruleset
- Loading branch information
1 parent
a58bb76
commit b67403d
Showing
11 changed files
with
13 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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 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
b67403d
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.
@seven-phases-max Does this look correct?
b67403d
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.
Yes.
Except that (if I'm not mistaken) if we also change this
isRulesetLike
flag toallowRoot
, we won't anymore need!ruleNode.isRulesetLike
in this condition at all.This flag for
Anonymous
ctor is set only by@import (inline)
result.b67403d
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.
Okay. I'll take a look at that (or you, whoever's first, lol). And then, probably for tests, we'll need to test pass / fail for nodes created by functions.
b67403d
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 was looking at the code, and the
isRulesetLike
property doesn't make sense to me. In Anonymous and Directive nodes, this is a function; in other places it's a boolean. If we just testruleNode.isRulesetLike
, then those two nodes will return true no matter what, since the function exists.What is this for, and what is it supposed to do?
b67403d
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.
Yes, and that's what I used it for there. Basically in my code that was a shortcut for
!= Directive || !=Anonymous || != Ruleset
).As for making sence, that's why I mentioned it's "broken" there. I suppose initially it was meant to mean exactly what
allowRoot
does, but later different people started to use it for different and even contradictory purposes (for example notice that in https://github.com/less/less.js/blob/master/lib/less/tree/directive.js#L39 the function returns nothing but justDirective.name !== "@charset"
:)b67403d
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.
Er..... okay. That's just hard to follow logically, because
ruleNode.isRulesetLike
will return true (or eval to true) even ifruleNode.isRulesetLike()
returns false. I assume you mean what you are saying, but then why not be consistent with isRulesetLike and use it as a boolean across all nodes, and just set a default value?Are we really sometimes setting that property to a function to return a value, sometimes as a value, and sometimes using it as a "truthy" evaluation? That just doesn't seem right. Do you know what I mean?
b67403d
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.
Just because this would mean you have to find all code where it's used and fix/refactor it to behave consistently :) It may be not so easy and it's just beyond the scope of the PR :) That's why above I suggested to get rid of it at all (just by changing it within
Anonymous
as it's the only place where we would care of it for the purposes of this branch).