Skip to content
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

fix: percentage with decimal point #845

Merged
merged 3 commits into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions integration_tests/specs/css/css-sizing/width.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,33 @@ describe('Width', function() {
await snapshot();
});

it('should work with percentage with decimal point', async () => {
let div;
div = createElement(
'div',
{
style: {
width: '200px',
height: '200px',
backgroundColor: 'green',
position: 'relative',
},
},
[
createElement('div', {
style: {
height: '100px',
width: '50.00%',
backgroundColor: 'yellow',
}
}),
]
);

BODY.appendChild(div);
await snapshot();
});

it('should work with percentage and multiple children in flow layout', async () => {
let div;
let foo;
Expand Down
2 changes: 1 addition & 1 deletion kraken/lib/src/css/values/percentage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import 'package:quiver/collection.dart';

final _percentageRegExp = RegExp(r'^[+-]?\d+\%$', caseSensitive: false);
final _percentageRegExp = RegExp(r'^[+-]?\d+[\.]?\d*\%$', caseSensitive: false);
final LinkedLruHashMap<String, double?> _cachedParsedPercentage = LinkedLruHashMap(maximumSize: 100);

class CSSPercentage {
Expand Down