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: border radius of one percentage value #1121

Merged
merged 2 commits into from Jan 21, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions integration_tests/specs/css/css-backgrounds/border-radius.ts
Expand Up @@ -71,6 +71,24 @@ describe('border_radius', () => {
await snapshot();
});

it('should work with percentage of one value on element of width and height not equal', async () => {
let div;
div = createElement(
'div',
{
style: {
width: '200px',
height: '100px',
backgroundColor: 'green',
borderRadius: '100%'
},
},
);

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

it('should work with percentage of two values', async () => {
let div;
div = createElement(
Expand Down
14 changes: 8 additions & 6 deletions kraken/lib/src/css/border.dart
Expand Up @@ -316,12 +316,14 @@ class CSSBorderRadius {
if (radius.isNotEmpty) {
// border-top-left-radius: horizontal vertical
List<String> values = radius.split(_splitRegExp);
if (values.length == 1) {
CSSLengthValue circular = CSSLength.parseLength(values[0], renderStyle, propertyName, Axis.horizontal);
return CSSBorderRadius(circular, circular);
} else if (values.length == 2) {
CSSLengthValue x = CSSLength.parseLength(values[0], renderStyle, propertyName, Axis.horizontal);
CSSLengthValue y = CSSLength.parseLength(values[1], renderStyle, propertyName, Axis.vertical);
if (values.length == 1 || values.length == 2) {
String horizontalRadius = values[0];
// The first value is the horizontal radius, the second the vertical radius.
// If the second value is omitted it is copied from the first.
// https://www.w3.org/TR/css-backgrounds-3/#border-radius
String verticalRadius = values.length == 1 ? values[0] : values[1];
CSSLengthValue x = CSSLength.parseLength(horizontalRadius, renderStyle, propertyName, Axis.horizontal);
CSSLengthValue y = CSSLength.parseLength(verticalRadius, renderStyle, propertyName, Axis.vertical);
return CSSBorderRadius(x, y);
}
}
Expand Down