Skip to content

Commit ca0c662

Browse files
committed
Handle "box-shadow: none, none"
1 parent bde5805 commit ca0c662

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/MoodleHQ/RTLCSS/Transformation/FlipShadow.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,16 @@ public function transform(Rule $rule)
3737
if ($value instanceof RuleValueList) {
3838
$parameters = $value->getListComponents();
3939
$index = $this->getOffsetXIndex($rule);
40-
/** @var Size $oldX */
41-
$oldX = $parameters[$index];
42-
$parameters[$index] = $this->sizeFlipper->invertSize($oldX);
40+
if ($index >= 0) {
41+
/** @var Size $oldX */
42+
$oldX = $parameters[$index];
43+
$parameters[$index] = $this->sizeFlipper->invertSize($oldX);
4344

44-
$value->setListComponents($parameters);
45+
$value->setListComponents($parameters);
46+
}
4547
}
48+
49+
return $value;
4650
}
4751

4852
/**
@@ -51,11 +55,9 @@ public function transform(Rule $rule)
5155
* @param Rule $rule
5256
*
5357
* @return int
54-
* @throws TransformationException
5558
*/
5659
private function getOffsetXIndex(Rule $rule)
5760
{
58-
$property = $rule->getRule();
5961
$value = $rule->getValue();
6062
if ($value instanceof RuleValueList) {
6163
$parameters = $value->getListComponents();
@@ -67,6 +69,7 @@ private function getOffsetXIndex(Rule $rule)
6769
}
6870
}
6971

70-
throw new TransformationException("Invalid value for \"$property\"");
72+
// handle other types like RuleValueList gracefully
73+
return -1;
7174
}
7275
}

0 commit comments

Comments
 (0)