Permalink
Browse files

Fix to issue 28, extending across multiple files

  • Loading branch information...
1 parent 5ae6504 commit 03af9f2aa0a16a94b714cb9bf807fd04a675e4f8 @richthegeek committed Jul 30, 2012
Showing with 33 additions and 23 deletions.
  1. +1 −0 VERSION
  2. +3 −0 test.php
  3. +1 −3 tests/extend.sass
  4. +4 −0 tests/extend_included.scss
  5. +9 −17 tests/nested-media.css
  6. +1 −1 tree/SassExtendNode.php
  7. +1 −0 tree/SassImportNode.php
  8. +11 −0 tree/SassRootNode.php
  9. +2 −2 tree/SassRuleNode.php
View
@@ -1,3 +1,4 @@
+Version 201207301030 - Fix to issue 28, extending from included files
Version 201207271000 - Fixed scale-color function (attrib: Steve Jones)
Version 201207262300 - Various issue fixes, better testing framework
Version 201206291700 - Fixed some tests, minor changes to string and import handling
View
@@ -78,6 +78,9 @@ function test_files($files, $dir = '.') {
$diff = exec('diff -ibwB /tmp/scss_test_0 /tmp/scss_test_1', $out);
if (count($out)) {
+ if (isset($_GET['full'])) {
+ $out[] = $result;
+ }
return implode("\n", $out);
} else {
return TRUE;
View
@@ -1,6 +1,4 @@
-.error
- border: 1px #f00
- background-color: #fdd
+@import extend_included.scss;
.seriousError
@extend .error
@@ -0,0 +1,4 @@
+.error {
+ border: 1px #f00;
+ background-color: #fdd;
+}
View
@@ -1,22 +1,14 @@
.sidebar {
- width: 300px;
-}
+ width: 300px; }
@media screen and (max-width: 1024px) {
.sidebar {
- width: 500px;
- }
- .sidebar .subclass {
- height: 100px;
- }
- .sidebar .subclass .subsubclass {
- height: 200px;
- }
-}
+ width: 500px; }
+ .sidebar .subclass {
+ height: 100px; }
+ .sidebar .subclass .subsubclass {
+ height: 200px; } }
@media screen and (max-width:1024px) {
.subclass {
- height: 100px
- }
- .subclass .subsubclass {
- height: 200px
- }
-}
+ height: 100px; }
+ .subclass .subsubclass {
+ height: 200px; } }
View
@@ -41,7 +41,7 @@ public function __construct($token) {
* @return array An empty array
*/
public function parse($context) {
- # Richard Lyon, 25/10/2011 - resolve selectors in relation to variables
+ # resolve selectors in relation to variables
# allows extend inside nested loops.
$this->root->extend($this->value, $this->parent->resolveSelectors($context));
return array();
View
@@ -72,6 +72,7 @@ public function parse($context) {
$tree->children = array();
} else {
$tree = new SassRootNode($this->parser);
+ $tree->extend_parent = $this->parent;
}
foreach ($files as $subfile) {
View
@@ -37,6 +37,11 @@ class SassRootNode extends SassNode {
public $extenders = array();
/**
+ * Extend_parent - for resolving extends across imported files.
+ */
+ public $extend_parent = null;
+
+ /**
* Root SassNode constructor.
* @param SassParser Sass parser
* @return SassNode
@@ -81,11 +86,17 @@ public function render() {
}
public function extend($extendee, $selectors) {
+ if ($this->extend_parent && method_exists($this->extend_parent, 'extend')) {
+ return $this->extend_parent->extend($extendee, $selectors);
+ }
$this->extenders[$extendee] = (isset($this->extenders[$extendee])
? array_merge($this->extenders[$extendee], $selectors) : $selectors);
}
public function getExtenders() {
+ if ($this->extend_parent && method_exists($this->extend_parent, 'getExtenders')) {
+ return $this->extend_parent->getExtenders();
+ }
return $this->extenders;
}
View
@@ -105,7 +105,7 @@ public function render() {
else {
$properties[] = $child->render();
}
- } // foreach
+ }
return $this->renderer->renderRule($this, $properties, $rules);
}
@@ -117,7 +117,7 @@ public function render() {
* $selector a selector or selector sequence that is to be extended
*/
public function extend() {
- foreach ($this->root->extenders as $extendee=>$extenders) {
+ foreach ($this->root->getExtenders() as $extendee => $extenders) {
if ($this->isPsuedo($extendee)) {
$extendee = explode(':', $extendee);
$pattern = preg_quote($extendee[0]).'((\.[-\w]+)*):'.preg_quote($extendee[1]);

0 comments on commit 03af9f2

Please sign in to comment.