-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Fix @plugin
scoping rules
#2522
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7a80a82
Add missing null check
rjgotten 4d17c8b
Fix plugin scope for mixins, directives and detached rulesets
rjgotten 56f5db8
Mend failing unit tests
rjgotten 0a6e2f8
merge changes from upstream
rjgotten 56687b9
Make functionRegistry in mxin definition inherit from mixinEnv
rjgotten aa66271
Deletes an accidentally committed dev file
rjgotten 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 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
.other { | ||
trans: transitive; | ||
} | ||
.class { | ||
trans: transitive; | ||
global: global; | ||
local: test-local(); | ||
shadow: global; | ||
} | ||
.class .local { | ||
global: global; | ||
local: local; | ||
shadow: local; | ||
} | ||
.class { | ||
ns-mixin-global: global; | ||
ns-mixin-local: local; | ||
ns-mixin-shadow: local; | ||
mixin-local: local; | ||
mixin-global: global; | ||
mixin-shadow: local; | ||
ruleset-local: local; | ||
ruleset-global: global; | ||
ruleset-shadow: local; | ||
class-local: test-local(); | ||
} | ||
@media screen { | ||
.test { | ||
result: global; | ||
} | ||
} | ||
@font-face { | ||
result: global; | ||
} | ||
@media screen and (min-width: 100px) and (max-width: 400px) { | ||
.test { | ||
result: global; | ||
} | ||
} | ||
@media screen { | ||
.test { | ||
result: local; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// importing plugin globally | ||
@plugin "./plugin/plugin-global"; | ||
|
||
// transitively include plugins from importing another sheet | ||
@import "./plugin/plugin-transitive"; | ||
|
||
|
||
// `test-global` function should be reachable | ||
// `test-local` function should not be reachable | ||
// `test-shadow` function should return global version | ||
.class { | ||
trans : test-transitive(); | ||
global : test-global(); | ||
local : test-local(); | ||
shadow : test-shadow(); | ||
|
||
// `test-global` function should propagate and be reachable | ||
// `test-local` function should be reachable | ||
// `test-shadow` function should return local version, shadowing global version | ||
.local { | ||
@plugin "./plugin/plugin-local"; | ||
global : test-global(); | ||
local : test-local(); | ||
shadow : test-shadow(); | ||
} | ||
} | ||
|
||
// calling a mixin or detached ruleset should not bubble local plugins | ||
// imported inside either into the parent scope. | ||
.mixin() { | ||
@plugin "./plugin/plugin-local"; | ||
mixin-local : test-local(); | ||
mixin-global : test-global(); | ||
mixin-shadow : test-shadow(); | ||
} | ||
@ruleset : { | ||
@plugin "./plugin/plugin-local"; | ||
ruleset-local : test-local(); | ||
ruleset-global : test-global(); | ||
ruleset-shadow : test-shadow(); | ||
}; | ||
#ns { | ||
@plugin "./plugin/plugin-local"; | ||
.mixin() { | ||
ns-mixin-global : test-global(); | ||
ns-mixin-local : test-local(); | ||
ns-mixin-shadow : test-shadow(); | ||
} | ||
} | ||
.class { | ||
#ns > .mixin(); | ||
.mixin(); | ||
@ruleset(); | ||
class-local : test-local(); | ||
} | ||
|
||
|
||
// `test-global` function should propagate into directive scope | ||
@media screen { | ||
.test { | ||
result : test-global(); | ||
} | ||
} | ||
@font-face { | ||
result : test-global(); | ||
} | ||
|
||
// `test-global` function should propagate into nested directive scopes | ||
@media screen and (min-width:100px) { | ||
@media (max-width:400px) { | ||
.test { | ||
result : test-global(); | ||
} | ||
} | ||
} | ||
|
||
.test { | ||
@media screen { | ||
@plugin "./plugin/plugin-local"; | ||
result : test-local(); | ||
} | ||
} | ||
|
||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
functions.addMultiple({ | ||
"test-shadow" : function() { | ||
return new tree.Anonymous( "global" ); | ||
}, | ||
"test-global" : function() { | ||
return new tree.Anonymous( "global" ); | ||
} | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
functions.addMultiple({ | ||
"test-shadow" : function() { | ||
return new tree.Anonymous( "local" ); | ||
}, | ||
"test-local" : function() { | ||
return new tree.Anonymous( "local" ); | ||
} | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
functions.addMultiple({ | ||
"test-transitive" : function() { | ||
return new tree.Anonymous( "transitive" ); | ||
} | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@plugin "plugin-transitive"; | ||
|
||
.other { | ||
trans : test-transitive(); | ||
} |
This file was deleted.
Oops, something went wrong.
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.
import and plugin directives inside detached rulesets didn't work as expected because the visitor was stopping at the rule level, never entering the detached ruleset declaration.
This change enables it for the simple form of
@var : { ... }
and verifies that scoping for plugin works as expected in that scenario. You may want to not take this particular change. Just notifying and trying to be clear.