Skip to content

Commit c182a31

Browse files
authored
fix: fix text decoration regressions (#1448)
1 parent d46cfde commit c182a31

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

lib/src/builtins/interactive_element_builtin.dart

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class InteractiveElementBuiltIn extends HtmlExtension {
3030
style: Style(
3131
color: Colors.blue,
3232
textDecoration: TextDecoration.underline,
33+
textDecorationColor: Colors.blue,
3334
),
3435
node: context.node,
3536
elementId: context.id,

lib/src/builtins/styled_element_builtin.dart

+11-3
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,17 @@ class StyledElementBuiltIn extends HtmlExtension {
414414
continue monospace;
415415
underline:
416416
case "u":
417-
styledElement.style = Style(
418-
textDecoration: TextDecoration.underline,
419-
);
417+
for (var child in styledElement.children) {
418+
if (child.attributes.containsKey("style")) {
419+
final newStyle = inlineCssToStyle(child.attributes["style"], null);
420+
if (newStyle != null) {
421+
styledElement.style = styledElement.style
422+
.merge(Style(textDecorationColor: newStyle.color));
423+
}
424+
}
425+
}
426+
styledElement.style = styledElement.style
427+
.merge(Style(textDecoration: TextDecoration.underline));
420428
break;
421429
case "var":
422430
continue italics;

lib/src/css_parser.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ Style declarationsToStyle(Map<String, List<css.Expression>> declarations) {
292292
style.border = newBorder;
293293
break;
294294
case 'color':
295-
style.color =
295+
style.color = style.textDecorationColor =
296296
ExpressionMapping.expressionToColor(value.first) ?? style.color;
297297
break;
298298
case 'direction':

lib/src/style.dart

+4
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,10 @@ class Style {
404404
child.textDecoration ?? TextDecoration.none,
405405
textDecoration ?? TextDecoration.none,
406406
]),
407+
textDecorationColor: child.textDecorationColor ?? textDecorationColor,
408+
textDecorationThickness:
409+
child.textDecorationThickness ?? textDecorationThickness,
410+
textDecorationStyle: child.textDecorationStyle ?? textDecorationStyle,
407411
textShadow: child.textShadow ?? textShadow,
408412
whiteSpace: child.whiteSpace ?? whiteSpace,
409413
wordSpacing: child.wordSpacing ?? wordSpacing,

0 commit comments

Comments
 (0)