Skip to content

Commit

Permalink
Make align=center work like CENTER tag (#1076)
Browse files Browse the repository at this point in the history
  • Loading branch information
daohoangson authored Oct 25, 2023
1 parent 4b878c4 commit 4fe02e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/core/lib/src/core_widget_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,12 @@ class WidgetFactory extends WidgetFactoryResetter with AnchorWidgetFactory {

static StylesMap _cssTextAlignFromAttribute(dom.Element element) {
final value = element.attributes[kAttributeAlign];

if (value == kCssTextAlignCenter) {
// `align=center` works more like `CENTER` tag, not `text-align: center`
return const {kCssTextAlign: kCssTextAlignWebkitCenter};
}

return value != null ? {kCssTextAlign: value} : const {};
}

Expand Down
3 changes: 2 additions & 1 deletion packages/core/test/style_text_align_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ void main() {
expect(
explained,
equals(
'[CssBlock:child=[RichText:align=center,(:_X_)]]',
'[CssBlock:child=[Center:heightFactor=1.0,child='
'[RichText:align=center,(:_X_)]]]',
),
);
});
Expand Down

1 comment on commit 4fe02e0

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.