diff --git a/lesscpy/plib/deferred.py b/lesscpy/plib/deferred.py index 842dfd6..b91a3bd 100644 --- a/lesscpy/plib/deferred.py +++ b/lesscpy/plib/deferred.py @@ -45,9 +45,6 @@ class Deferred(Node): ident.parse(scope) mixins = scope.mixins(ident.raw()) -# if scope.real: -# print(scope.real[-1].raw()) - if not mixins: ident.parse(None) mixins = scope.mixins(ident.raw()) @@ -78,6 +75,7 @@ class Deferred(Node): if mixins: for mixin in mixins: + scope.current = scope.real[-1] if scope.real else None res = mixin.call(scope, args) if res: # Add variables to scope to support diff --git a/lesscpy/test/css/mixin-args-recursive.css b/lesscpy/test/css/mixin-args-recursive.css index 7b7b90a..a5b5df3 100644 --- a/lesscpy/test/css/mixin-args-recursive.css +++ b/lesscpy/test/css/mixin-args-recursive.css @@ -34,3 +34,36 @@ .a .span1 { width: 12px; } +.span3 { + width: 60px; +} +.span2 { + width: 36px; +} +.span1 { + width: 12px; +} +.nested { + padding: 1px; +} +.nested .span3 { + width: 60px; +} +.nested .span2 { + width: 36px; +} +.nested .span1 { + width: 12px; +} +.nested .deep { + padding: 1px; +} +.nested .deep .span3 { + width: 60px; +} +.nested .deep .span2 { + width: 36px; +} +.nested .deep .span1 { + width: 12px; +} diff --git a/lesscpy/test/css/mixin-args-recursive.min.css b/lesscpy/test/css/mixin-args-recursive.min.css index da4612d..963cbba 100644 --- a/lesscpy/test/css/mixin-args-recursive.min.css +++ b/lesscpy/test/css/mixin-args-recursive.min.css @@ -10,3 +10,14 @@ .a .span3{width:60px;} .a .span2{width:36px;} .a .span1{width:12px;} +.span3{width:60px;} +.span2{width:36px;} +.span1{width:12px;} +.nested{padding:1px;} +.nested .span3{width:60px;} +.nested .span2{width:36px;} +.nested .span1{width:12px;} +.nested .deep{padding:1px;} +.nested .deep .span3{width:60px;} +.nested .deep .span2{width:36px;} +.nested .deep .span1{width:12px;} diff --git a/lesscpy/test/less/mixin-args-recursive.less b/lesscpy/test/less/mixin-args-recursive.less index 0c27764..4cb0988 100644 --- a/lesscpy/test/less/mixin-args-recursive.less +++ b/lesscpy/test/less/mixin-args-recursive.less @@ -12,4 +12,33 @@ .a { .spanX(12); -} \ No newline at end of file +} +// Nested recursion +@gridColumns: 3; +@gridColumnWidth: 60px; +@gridGutterWidth: 20px; +#grid { + .core (@gridColumnWidth, @gridGutterWidth) { + .spanX (@index) when (@index > 0) { + (~".span@{index}") { .span(@index); } + .spanX(@index - 1); + } + .spanX (0) {} + + .span (@columns) { + width: (@gridColumnWidth * @columns) + (@gridGutterWidth * (@columns - 1)); + } + + .spanX (@gridColumns); + + .nested { + padding: 1px; + .spanX (@gridColumns); + .deep { + padding: 1px; + .spanX (@gridColumns); + } + } + } +} +#grid > .core(@gridColumnWidth, @gridGutterWidth); \ No newline at end of file