-
Notifications
You must be signed in to change notification settings - Fork 59
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
Unconfigured props will be overwritten if a new undefined value is not passed in #376
Conversation
3361a0e
to
978e5ca
Compare
depends on #377 |
I'm working in tests for this use case. |
03b6b4f
to
f9d3461
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @diegonvs, this looks good! I think it can be simplified a little bit.
We probably don't need to keep array.dedupe
moving forward, as it's pretty straightforward to do it using a Set
.
I'm pinging @bryceosterhaus and @mthadley to validate this as well.
Thanks! :)
packages/metal/src/array/array.js
Outdated
deduped.push(arr[i]); | ||
} | ||
} | ||
return deduped; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @diegonvs, I think this all could be simply...
return arr.filter(
(elem, pos) => {
return arr.indexOf(elem) === pos;
}
);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://jsperf.com/filter-vs-for-to-dedupe-an-array
Using for
is more performatic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a premature optimization. We can get there if needed :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In any case, since we're not going to need it for now, let's simply remove it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay 😂
let keys = Object.keys(data); | ||
let keys = array.dedupe( | ||
Object.keys(data).concat(Object.keys(component.props)) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be simplified to:
const keys = new Set([...Object.keys(data), ...Object.keys(component.props]);
keys.forEach(
key => {
...
}
);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, I'll use it.
@@ -411,6 +411,83 @@ describe('JSXComponent', function() { | |||
assert.strictEqual(component.element, child.element); | |||
}); | |||
|
|||
it('should not overwrite unconfigured props if a new undefined value is not passed', function( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bryceosterhaus, @mthadley, mind taking a look to see if this matches your expectations?
@jbalsas , Could you rerun travis? |
7acc6a5
to
a1cbde4
Compare
…ster on github | Fixes metal#374
184e9b9
to
917503c
Compare
Thanks @diegonvs! I'm merging this and plan to release all we've been accumulating some time next week. |
No description provided.