Skip to content

Commit 572513a

Browse files
committed
The SCSS compiler mistakes some strings as namespaced modules
See https://www.woltlab.com/community/thread/314508/
1 parent f24343f commit 572513a

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

wcfsetup/install/files/lib/system/style/StyleCompiler.class.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace wcf\system\style;
44

55
use ScssPhp\ScssPhp\Compiler;
6+
use ScssPhp\ScssPhp\Exception\SassException;
67
use ScssPhp\ScssPhp\OutputStyle;
78
use ScssPhp\ScssPhp\ValueConverter;
89
use wcf\data\application\Application;
@@ -705,20 +706,18 @@ private function prepareFile(string $filename): string
705706
private function compileStylesheet(string $scss, array $variables): string
706707
{
707708
$compiler = $this->makeCompiler();
708-
$compiler->replaceVariables(\array_map(static function ($value) {
709+
$compiler->replaceVariables(\array_map(static function ($value) use (&$i) {
709710
if ($value === "" || \is_int($value)) {
710711
return ValueConverter::fromPhp($value);
711712
}
712713

713-
// The SCSS v2 compiler trips over string values when trying to feed
714-
// them into `parseValue()`. Explicitly treating them as strings
715-
// when they are not numeric fixes this while preserving the ability
716-
// to work with numbers passed as strings.
717-
if (\is_string($value) && !\is_numeric($value)) {
718-
return ValueConverter::fromPhp($value);
714+
try {
715+
return ValueConverter::parseValue($value);
716+
} catch (SassException $e) {
717+
if (\str_contains($e->getMessage(), 'Sass modules are not implemented yet')) {
718+
return ValueConverter::fromPhp($value);
719+
}
719720
}
720-
721-
return ValueConverter::parseValue($value);
722721
}, $variables));
723722

724723
try {

0 commit comments

Comments
 (0)