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

Unconfigured props will be overwritten if a new undefined value is not passed in #376

Merged
merged 6 commits into from
Jul 20, 2018

Conversation

diegonvs
Copy link
Contributor

No description provided.

@diegonvs diegonvs force-pushed the jsx-unconfigured-props branch from 3361a0e to 978e5ca Compare May 16, 2018 18:40
@diegonvs diegonvs changed the title WIP: #374 Unconfigured props will be overwritten if a new undefined value is not passed in May 16, 2018
@diegonvs
Copy link
Contributor Author

depends on #377

@diegonvs diegonvs changed the title Unconfigured props will be overwritten if a new undefined value is not passed in WIP: Unconfigured props will be overwritten if a new undefined value is not passed in May 16, 2018
@diegonvs
Copy link
Contributor Author

I'm working in tests for this use case.

@diegonvs diegonvs force-pushed the jsx-unconfigured-props branch from 03b6b4f to f9d3461 Compare May 16, 2018 20:27
@diegonvs diegonvs changed the title WIP: Unconfigured props will be overwritten if a new undefined value is not passed in Unconfigured props will be overwritten if a new undefined value is not passed in May 16, 2018
Copy link
Contributor

@jbalsas jbalsas left a 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! :)

deduped.push(arr[i]);
}
}
return deduped;
Copy link
Contributor

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;
    }
);

Copy link
Contributor Author

@diegonvs diegonvs Jul 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

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 :)

Copy link
Contributor

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

Copy link
Contributor Author

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))
);
Copy link
Contributor

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 => {
        ...
    }
);

Copy link
Contributor Author

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(
Copy link
Contributor

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?

@diegonvs
Copy link
Contributor Author

@jbalsas , Could you rerun travis?

@diegonvs diegonvs force-pushed the jsx-unconfigured-props branch from 7acc6a5 to a1cbde4 Compare July 19, 2018 17:01
@diegonvs diegonvs force-pushed the jsx-unconfigured-props branch from 184e9b9 to 917503c Compare July 19, 2018 17:24
@jbalsas jbalsas merged commit 5cf7357 into metal:develop Jul 20, 2018
@jbalsas
Copy link
Contributor

jbalsas commented Jul 20, 2018

Thanks @diegonvs! I'm merging this and plan to release all we've been accumulating some time next week.

@diegonvs diegonvs deleted the jsx-unconfigured-props branch July 20, 2018 17:45
@diegonvs diegonvs restored the jsx-unconfigured-props branch July 20, 2018 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants