Skip to content

Commit 6ce25f6

Browse files
authored
Merge pull request Sub6Resources#557 from tneotia/bugfix/bad-state
Hotfix for bad-state no element bug on certain text decorations
2 parents b5c5ea0 + c71774c commit 6ce25f6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/src/css_parser.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ Style declarationsToStyle(Map<String, List<css.Expression>> declarations) {
4646
List<css.LiteralTerm> textDecorationList = value.whereType<css.LiteralTerm>().toList();
4747
/// List<css.LiteralTerm> might include other values than the ones we want for [textDecorationList], so make sure to remove those before passing it to [ExpressionMapping]
4848
textDecorationList.removeWhere((element) => element.text != "none" && element.text != "overline" && element.text != "underline" && element.text != "line-through");
49-
css.Expression textDecorationColor = value.firstWhere((element) => element is css.HexColorTerm || element is css.FunctionTerm, orElse: null);
50-
List<css.LiteralTerm> temp = value.whereType<css.LiteralTerm>().toList();
49+
css.Expression textDecorationColor = value.firstWhere((element) => element is css.HexColorTerm || element is css.FunctionTerm, orElse: () => null);
50+
List<css.LiteralTerm> potentialStyles = value.whereType<css.LiteralTerm>().toList();
5151
/// List<css.LiteralTerm> might include other values than the ones we want for [textDecorationStyle], so make sure to remove those before passing it to [ExpressionMapping]
52-
temp.removeWhere((element) => element.text != "solid" && element.text != "double" && element.text != "dashed" && element.text != "dotted" && element.text != "wavy");
53-
css.LiteralTerm textDecorationStyle = temp.last ?? null;
52+
potentialStyles.removeWhere((element) => element.text != "solid" && element.text != "double" && element.text != "dashed" && element.text != "dotted" && element.text != "wavy");
53+
css.LiteralTerm textDecorationStyle = potentialStyles.isNotEmpty ? potentialStyles?.last : null;
5454
style.textDecoration = ExpressionMapping.expressionToTextDecorationLine(textDecorationList);
5555
if (textDecorationColor != null) style.textDecorationColor = ExpressionMapping.expressionToColor(textDecorationColor);
5656
if (textDecorationStyle != null) style.textDecorationStyle = ExpressionMapping.expressionToTextDecorationStyle(textDecorationStyle);

0 commit comments

Comments
 (0)