MDL-67379 libraries: Upgrade scssphp to 1.0.6

This commit is contained in:
Shamim Rezaie
2020-01-16 00:26:47 +11:00
parent 77be1e3fe3
commit e27ac65f3d
13 changed files with 1412 additions and 717 deletions
+30 -14
View File
@@ -63,24 +63,13 @@ class Nested extends Formatter
foreach ($block->lines as $index => $line) {
if (substr($line, 0, 2) === '/*') {
$block->lines[$index] = preg_replace('/(\r|\n)+/', $glue, $line);
$block->lines[$index] = preg_replace('/[\r\n]+/', $glue, $line);
}
}
$this->write($inner . implode($glue, $block->lines));
}
protected function hasFlatChild($block)
{
foreach ($block->children as $child) {
if (empty($child->selectors)) {
return true;
}
}
return false;
}
/**
* {@inheritdoc}
*/
@@ -109,7 +98,7 @@ class Nested extends Formatter
array_pop($depths);
$this->depth--;
if (!$this->depth && ($block->depth <= 1 || (!$this->indentLevel && $block->type === Type::T_COMMENT)) &&
if (! $this->depth && ($block->depth <= 1 || (! $this->indentLevel && $block->type === Type::T_COMMENT)) &&
(($block->selectors && ! $isMediaOrDirective) || $previousHasSelector)
) {
$downLevel = $this->break;
@@ -170,15 +159,18 @@ class Nested extends Formatter
}
$this->blockLines($block);
$closeBlock = $this->break;
}
if (! empty($block->children)) {
if ($this->depth>0 && ($isMediaOrDirective || ! $this->hasFlatChild($block))) {
if ($this->depth > 0 && ($isMediaOrDirective || ! $this->hasFlatChild($block))) {
array_pop($depths);
$this->depth--;
$this->blockChildren($block);
$this->depth++;
$depths[] = $block->depth;
} else {
$this->blockChildren($block);
@@ -193,13 +185,19 @@ class Nested extends Formatter
if (! empty($block->selectors)) {
$this->indentLevel--;
if (! $this->keepSemicolons) {
$this->strippedSemicolon = '';
}
$this->write($this->close);
$closeBlock = $this->break;
if ($this->depth > 1 && ! empty($block->children)) {
array_pop($depths);
$this->depth--;
}
if (! $isMediaOrDirective) {
$previousHasSelector = true;
}
@@ -209,4 +207,22 @@ class Nested extends Formatter
$this->write($this->break);
}
}
/**
* Block has flat child
*
* @param \ScssPhp\ScssPhp\Formatter\OutputBlock $block
*
* @return boolean
*/
private function hasFlatChild($block)
{
foreach ($block->children as $child) {
if (empty($child->selectors)) {
return true;
}
}
return false;
}
}