Skip to content

Fix text decorations #1448

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/src/builtins/interactive_element_builtin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class InteractiveElementBuiltIn extends HtmlExtension {
style: Style(
color: Colors.blue,
textDecoration: TextDecoration.underline,
textDecorationColor: Colors.blue,
),
node: context.node,
elementId: context.id,
Expand Down
14 changes: 11 additions & 3 deletions lib/src/builtins/styled_element_builtin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,17 @@
continue monospace;
underline:
case "u":
styledElement.style = Style(
textDecoration: TextDecoration.underline,
);
for (var child in styledElement.children) {
if (child.attributes.containsKey("style")) {
final newStyle = inlineCssToStyle(child.attributes["style"], null);

Check warning on line 419 in lib/src/builtins/styled_element_builtin.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/builtins/styled_element_builtin.dart#L419

Added line #L419 was not covered by tests
if (newStyle != null) {
styledElement.style = styledElement.style
.merge(Style(textDecorationColor: newStyle.color));

Check warning on line 422 in lib/src/builtins/styled_element_builtin.dart

View check run for this annotation

Codecov / codecov/patch

lib/src/builtins/styled_element_builtin.dart#L421-L422

Added lines #L421 - L422 were not covered by tests
}
}
}
styledElement.style = styledElement.style
.merge(Style(textDecoration: TextDecoration.underline));
break;
case "var":
continue italics;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/css_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ Style declarationsToStyle(Map<String, List<css.Expression>> declarations) {
style.border = newBorder;
break;
case 'color':
style.color =
style.color = style.textDecorationColor =
ExpressionMapping.expressionToColor(value.first) ?? style.color;
break;
case 'direction':
Expand Down
4 changes: 4 additions & 0 deletions lib/src/style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,10 @@ class Style {
child.textDecoration ?? TextDecoration.none,
textDecoration ?? TextDecoration.none,
]),
textDecorationColor: child.textDecorationColor ?? textDecorationColor,
textDecorationThickness:
child.textDecorationThickness ?? textDecorationThickness,
textDecorationStyle: child.textDecorationStyle ?? textDecorationStyle,
textShadow: child.textShadow ?? textShadow,
whiteSpace: child.whiteSpace ?? whiteSpace,
wordSpacing: child.wordSpacing ?? wordSpacing,
Expand Down