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/fix regex match error for time #390

Merged
merged 2 commits into from
Jun 15, 2023
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
4 changes: 2 additions & 2 deletions webf/lib/src/css/display.dart
Expand Up @@ -34,9 +34,9 @@ mixin CSSDisplayMixin on RenderStyle {
}
}

void initDisplay() {
void initDisplay(CSSStyleDeclaration style) {
// Must take from style because it inited before flush pending properties.
_display ??= resolveDisplay(target.style[DISPLAY]);
_display ??= resolveDisplay(style[DISPLAY]);
}

static CSSDisplay resolveDisplay(String? displayString) {
Expand Down
2 changes: 1 addition & 1 deletion webf/lib/src/css/values/time.dart
Expand Up @@ -5,7 +5,7 @@

import 'package:quiver/collection.dart';

final _timeRegExp = RegExp(r'^[+-]?(\d+)?(\.\d+)?ms|s$', caseSensitive: false);
final _timeRegExp = RegExp(r'^[+-]?(\d+)?(\.\d+)?(?:ms|s){1}$', caseSensitive: false);
final _0s = '0s';
final _0ms = '0ms';
final LinkedLruHashMap<String, int?> _cachedParsedTime = LinkedLruHashMap(maximumSize: 100);
Expand Down
2 changes: 1 addition & 1 deletion webf/lib/src/dom/element.dart
Expand Up @@ -1738,7 +1738,7 @@ abstract class Element extends ContainerNode with ElementBase, ElementEventMixin
// Apply default style.
_applyDefaultStyle(style);
// Init display from style directly cause renderStyle is not flushed yet.
renderStyle.initDisplay();
renderStyle.initDisplay(style);

applyAttributeStyle(style);
_applyInlineStyle(style);
Expand Down
7 changes: 7 additions & 0 deletions webf/test/src/css/style_sheet_parser.dart
Expand Up @@ -82,5 +82,12 @@ void main() {
expect((rules[0] as CSSStyleRule).selectorGroup.selectorText, '.foo');
expect((rules[0] as CSSStyleRule).declaration.getPropertyValue('color'), 'red');
});
test('9', () {
List<CSSRule> rules = parseRules('.item { animation: testAni .5s 1 ease forwards }');
expect(rules.length, 1);
expect((rules[0] as CSSStyleRule).selectorGroup.selectorText, '.item');
expect((rules[0] as CSSStyleRule).declaration.getPropertyValue('animationDelay'), '0s');
andycall marked this conversation as resolved.
Show resolved Hide resolved
expect((rules[0] as CSSStyleRule).declaration.getPropertyValue('animationFillMode'), 'forwards');
});
});
}