From e52bba6b2be131114ccc1f0ea19aefdb58943fbf Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Wed, 7 Nov 2012 21:20:56 +0100 Subject: [PATCH 1/4] Added the failing test for recursive mixins --- tests/inputs/recursion.less | 23 +++++++++++++++++++++++ tests/outputs/recursion.css | 18 ++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 tests/inputs/recursion.less create mode 100644 tests/outputs/recursion.css diff --git a/tests/inputs/recursion.less b/tests/inputs/recursion.less new file mode 100644 index 00000000..36655e7a --- /dev/null +++ b/tests/inputs/recursion.less @@ -0,0 +1,23 @@ +.set(@width) { + .spanX(@index)when (@index > 0) { + (~".span@{index}") { + width: @width; + } + .spanX(@index - 1); + } + + .spanX(0) { + } + + .row { + .spanX (3); + } +} + +.set1 { + .set(10px); +} + +.set2 { + .set(33px); +} diff --git a/tests/outputs/recursion.css b/tests/outputs/recursion.css new file mode 100644 index 00000000..a3e3eecf --- /dev/null +++ b/tests/outputs/recursion.css @@ -0,0 +1,18 @@ +.set1 .row .span3 { + width: 10px; +} +.set1 .row .span2 { + width: 10px; +} +.set1 .row .span1 { + width: 10px; +} +.set2 .row .span3 { + width: 33px; +} +.set2 .row .span2 { + width: 33px; +} +.set2 .row .span1 { + width: 33px; +} From 225db6bb7f76a1f7b2a3b81b2235f81eda7b4bdc Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Wed, 7 Nov 2012 21:39:48 +0100 Subject: [PATCH 2/4] Fixed the handling of recursive closures. Fixes #324 --- lessc.inc.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/lessc.inc.php b/lessc.inc.php index aaa86930..cc8f45a0 100644 --- a/lessc.inc.php +++ b/lessc.inc.php @@ -282,7 +282,6 @@ protected function sortProps($props, $split = false) { $vars = array(); $imports = array(); $other = array(); - foreach ($props as $prop) { switch ($prop[0]) { case "assign": @@ -648,7 +647,6 @@ protected function compileProp($prop, $block, $out) { } $oldParent = $mixin->parent; - if ($mixin != $block) $mixin->parent = $block; foreach ($this->sortProps($mixin->props) as $subProp) { if ($suffix !== null && From f3ffcbd113975f4f2c9a9bb6474acd40ae20aca7 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Wed, 7 Nov 2012 23:34:32 +0100 Subject: [PATCH 3/4] Fixed the bootstrap testing on PHP 5.3 --- tests/bootstrap.sh | 4 ++-- tests/sort.php | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/bootstrap.sh b/tests/bootstrap.sh index db0ae3a2..a9d0d154 100755 --- a/tests/bootstrap.sh +++ b/tests/bootstrap.sh @@ -6,7 +6,7 @@ echo "have git and lessc installed." echo "" if [ -z "$input" ]; then - input="bootstrap/less/bootstrap.less" + input="bootstrap/less/responsive.less" fi dest=$(basename "$input") dest="${dest%.*}" @@ -28,7 +28,7 @@ echo ">> lessc compilation ($input)" lessc "$input" "tmp/$dest.lessc.css" echo ">> lessphp compilation ($input)" -../plessc "$input" "tmp/$dest.lessphp.css" +php ../plessc "$input" "tmp/$dest.lessphp.css" echo ">> Cleanup and convert" php sort.php "tmp/$dest.lessc.css" > "tmp/$dest.lessc.clean.css" diff --git a/tests/sort.php b/tests/sort.php index 70b907ea..af7a9e2e 100644 --- a/tests/sort.php +++ b/tests/sort.php @@ -34,8 +34,9 @@ function sortKey($block) { } function sortBlock($block) { - usort($block->children, function($a, $b) { - $sort = strcmp($this->sortKey($a), $this->sortKey($b)); + $that = $this; + usort($block->children, function($a, $b) use ($that) { + $sort = strcmp($that->sortKey($a), $that->sortKey($b)); if ($sort == 0) { // TODO } From 33c08b576cb90df625087aeba89814150073ed39 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Wed, 7 Nov 2012 23:57:04 +0100 Subject: [PATCH 4/4] Removed useless statements --- lessc.inc.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lessc.inc.php b/lessc.inc.php index cc8f45a0..9737e54e 100644 --- a/lessc.inc.php +++ b/lessc.inc.php @@ -282,6 +282,7 @@ protected function sortProps($props, $split = false) { $vars = array(); $imports = array(); $other = array(); + foreach ($props as $prop) { switch ($prop[0]) { case "assign": @@ -646,8 +647,6 @@ protected function compileProp($prop, $block, $out) { $this->zipSetArgs($mixin->args, $args); } - $oldParent = $mixin->parent; - foreach ($this->sortProps($mixin->props) as $subProp) { if ($suffix !== null && $subProp[0] == "assign" && @@ -663,8 +662,6 @@ protected function compileProp($prop, $block, $out) { $this->compileProp($subProp, $mixin, $out); } - $mixin->parent = $oldParent; - if ($haveArgs) $this->popEnv(); if ($haveScope) $this->popEnv(); }