Skip to content

Fix @plugin scoping rules - #2522

Merged
lukeapage merged 6 commits into
less:masterfrom
rjgotten:fix-plugin-scoping
Apr 1, 2015
Merged

lukeapage merged 6 commits into
less:masterfrom
rjgotten:fix-plugin-scoping

Conversation

@rjgotten

Copy link
Copy Markdown
Contributor

This pull request fixes remaining scoping issues with the @plugin mechanic that #2479 introduced.

  • @plugin inside a directive block is now in scope for descendants of the directive block.
  • Mixins now properly inherit functions from definition scope. This was mistakingly using the caller scope.
  • Updated the unit tests for @plugin to cover scope inheritance and shadowing cases.

Fixed scope for plugins to apply correctly for mixins, directives and
detached rulesets.
Updated plugin unit tests to be more comprehensive
functionRegistry was mistakingly inheriting from the top frame of the
caller context, which was incorrect. It should inherit from definition
scope.
@rjgotten rjgotten changed the title Fix plugin scoping rules Fix @plugin scoping rules Mar 23, 2015
@rjgotten rjgotten mentioned this pull request Mar 23, 2015
Comment thread bin/test.less Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this file checked in by mistake?

@rjgotten

Copy link
Copy Markdown
Contributor Author

was this file checked in by mistake?

Oops. Yes. I thought I flagged that one as 'do not commit'. Maybe the GitHub client glitched.

@rjgotten

Copy link
Copy Markdown
Contributor Author

There we go. Deleted and ammended.

Copy link
Copy Markdown
Contributor Author

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.

lukeapage added a commit that referenced this pull request Apr 1, 2015
@lukeapage
lukeapage merged commit 86fa4f6 into less:master Apr 1, 2015
@rjgotten
rjgotten deleted the fix-plugin-scoping branch April 24, 2015 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants