-
Notifications
You must be signed in to change notification settings - Fork 213
Add interpolation support selector. #627
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,14 +18,17 @@ | |
| "psr-4": { "Leafo\\ScssPhp\\": "src/" } | ||
| }, | ||
| "autoload-dev": { | ||
| "psr-4": { "Leafo\\ScssPhp\\Test\\": "tests/" } | ||
| "psr-4": { "Leafo\\ScssPhp\\Test\\": "tests/" }, | ||
| "classmap": [ | ||
| "src/" | ||
| ] | ||
| }, | ||
| "require": { | ||
| "php": ">=5.4.0" | ||
| }, | ||
| "require-dev": { | ||
| "squizlabs/php_codesniffer": "~2.5", | ||
| "phpunit/phpunit": "~4.6" | ||
| "phpunit/phpunit": "^7" | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe phpunit7 requires php^7.1, but scssphp only requires php>=5.4.0 |
||
| }, | ||
| "bin": ["bin/pscss"], | ||
| "archive": { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -796,6 +796,8 @@ protected function compileAtRoot(Block $block) | |
|
|
||
| $this->env = $this->filterWithout($envs, $without); | ||
| $newBlock = $this->spliceTree($envs, $block, $without); | ||
| if (isset($block->atrootParent)) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure about this projects coding standard, but I'm pretty sure using |
||
| $newBlock[1]->atrootParent = $block->atrootParent; | ||
|
|
||
| $saveScope = $this->scope; | ||
| $this->scope = $this->rootBlock; | ||
|
|
@@ -1293,6 +1295,9 @@ protected function hasSelectorPlaceholder($selector) | |
|
|
||
| foreach ($selector as $parts) { | ||
| foreach ($parts as $part) { | ||
| if (is_array($part)) { | ||
| return false; | ||
| } | ||
| if (strlen($part) && '%' === $part[0]) { | ||
| return true; | ||
| } | ||
|
|
@@ -1878,7 +1883,11 @@ protected function compileChild($child, OutputBlock $out) | |
| if (isset($mixin->args)) { | ||
| $this->applyArguments($mixin->args, $argValues); | ||
| } | ||
|
|
||
| foreach ($mixin->children as $stm) { | ||
| if ($stm[0] == Type::T_AT_ROOT) { | ||
| $stm[1]->atrootParentSelectors = $callingScope->selectors; | ||
| } | ||
| } | ||
| $this->env->marker = 'mixin'; | ||
|
|
||
| $this->compileChildrenNoReturn($mixin->children, $out); | ||
|
|
@@ -2912,8 +2921,16 @@ protected function multiplySelectors(Environment $env) | |
| if (empty($env->selectors)) { | ||
| continue; | ||
| } | ||
|
|
||
| if ($env->block->type == Type::T_AT_ROOT) { | ||
| break; | ||
| } | ||
| $selectors = []; | ||
| if (!empty($env->block->parent->atrootParent) && !empty($env->block->parent->atrootParent->selectors)) { | ||
| $parentSelectors = $env->block->parent->atrootParent->selectors; | ||
| } | ||
| if (!empty($env->parent->parent->block->atrootParentSelectors)) { | ||
| $parentSelectors = $env->parent->parent->block->atrootParentSelectors; | ||
| } | ||
|
|
||
| foreach ($env->selectors as $selector) { | ||
| foreach ($parentSelectors as $parent) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -715,6 +715,7 @@ protected function pushBlock($selectors, $pos = 0) | |
| $b->selectors = $selectors; | ||
| $b->comments = []; | ||
| $b->parent = $this->env; | ||
| $b->atrootParent = $this->env; | ||
|
|
||
| if (! $this->env) { | ||
| $b->children = []; | ||
|
|
@@ -762,7 +763,9 @@ protected function popBlock() | |
| if (empty($block->parent)) { | ||
| $this->throwParseError('unexpected }'); | ||
| } | ||
|
|
||
| // if ($block->type == Type::T_AT_ROOT || $block->type == Type::T_MIXIN || $block->type == Type::T_INCLUDE) { | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume this commented code should just not be included, if its not in use. |
||
| // $block->atrootParent = $block->parent; | ||
| // } | ||
| $this->env = $block->parent; | ||
| unset($block->parent); | ||
|
|
||
|
|
@@ -1897,18 +1900,35 @@ protected function interpolation(&$out, $lookWhite = true) | |
| { | ||
| $oldWhite = $this->eatWhiteDefault; | ||
| $this->eatWhiteDefault = true; | ||
| $selector = false; | ||
|
|
||
| $s = $this->seek(); | ||
|
|
||
| if ($this->literal('#{') && $this->valueList($value) && $this->literal('}', false)) { | ||
|
|
||
| if ($lookWhite) { | ||
| $left = preg_match('/\s/', $this->buffer[$s - 1]) ? ' ' : ''; | ||
| $right = preg_match('/\s/', $this->buffer[$this->count]) ? ' ': ''; | ||
| $right = preg_match('/\s/', $this->buffer[$this->count]) ? ' ' : ''; | ||
| } else { | ||
| $left = $right = false; | ||
| } | ||
|
|
||
| $out = [Type::T_INTERPOLATE, $value, $left, $right]; | ||
|
|
||
| $this->eatWhiteDefault = $oldWhite; | ||
|
|
||
| if ($this->eatWhiteDefault) { | ||
| $this->whitespace(); | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| $this->seek($s); | ||
|
|
||
| if ($this->literal('#{') && $selector = $this->selectorSingle($sel) && $this->literal('}', false)) { | ||
|
|
||
| $out = $sel[0]; | ||
|
|
||
| $this->eatWhiteDefault = $oldWhite; | ||
|
|
||
| if ($this->eatWhiteDefault) { | ||
|
|
@@ -2095,6 +2115,11 @@ protected function selectorSingle(&$out) | |
| $parts[] = Compiler::$selfSelector; | ||
| continue; | ||
| } | ||
| // self | ||
| // if ($this->literal('#{&}', true)) { | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i assume unused commented code should just be removed |
||
| // $parts[] = Compiler::$selfSelector; | ||
| // continue; | ||
| // } | ||
|
|
||
| if ($this->literal('.', false)) { | ||
| $parts[] = '.'; | ||
|
|
||
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.
Why add classmap here?