Skip to content

Commit

Permalink
fix: percentage with decimal point (#845)
Browse files Browse the repository at this point in the history
* fix: add decimal support for percentage

* test: add test for decimal percentage
  • Loading branch information
temper357 committed Nov 23, 2021
1 parent 9197146 commit 7df079a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
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

0 comments on commit 7df079a

Please sign in to comment.