Skip to content

Commit

Permalink
Fix UiComponent2.consumedProps regression
Browse files Browse the repository at this point in the history
+ Previously, if `UiComponent2.consumedProps` was an empty list, it would throw a runtime exception.
+ This was a regression in `UiComponent2` for consumers migrating from `UiComponent`.
  • Loading branch information
aaronlademann-wf committed Nov 12, 2019
1 parent 9d0553d commit f2b6441
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/src/util/map_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void forwardUnconsumedProps(Map props, {
for (String key in props.keys) {
if (keysToOmit != null && keysToOmit.contains(key)) continue;

if (keySetsToOmit != null) {
if (keySetsToOmit != null && keySetsToOmit.isNotEmpty) {
/// If the passed in value of [keySetsToOmit] comes from
/// [addUnconsumedProps], there should only be a single index.
/// Consequently, this case exists to give the opportunity for the loop
Expand Down
24 changes: 24 additions & 0 deletions test/over_react/util/map_util_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,30 @@ main() {

expect(actual, equals(expected));
});

test('when keySetsToOmit is empty', () {
var actual = {};

forwardUnconsumedProps({
'prop 1': 'my prop #1',
'prop 2': 'my prop #2',
'prop 3': 'my prop #3',
'prop 4': 'my prop #4',
'prop 5': 'my prop #5',
'prop 6': 'my prop #6',
}, keySetsToOmit: [], propsToUpdate: actual);

var expected = {
'prop 1': 'my prop #1',
'prop 2': 'my prop #2',
'prop 3': 'my prop #3',
'prop 4': 'my prop #4',
'prop 5': 'my prop #5',
'prop 6': 'my prop #6',
};

expect(actual, equals(expected));
});

test('with only valid DOM/SVG props', () {
var actual = {};
Expand Down

0 comments on commit f2b6441

Please sign in to comment.