Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

support undefined as value #14

Merged
merged 1 commit into from
Jul 28, 2018
Merged

Conversation

jelhan
Copy link
Contributor

@jelhan jelhan commented Jul 14, 2018

No description provided.

@jelhan
Copy link
Contributor Author

jelhan commented Jul 14, 2018

This is caused by a bug in ember's set method: emberjs/ember.js#14270 It should be fixed on latest releases: emberjs/ember.js#16417 Travis/ember-try picks old versions. ember-release uses 2.18.1 and ember-beta is 3.0.0-beta.2-beta+b4135dfe.

@jelhan jelhan force-pushed the support-undefined branch from 712073f to ab5fc28 Compare July 14, 2018 12:14
@jelhan jelhan changed the title failing test: supports setting to undefined support undefined as value Jul 14, 2018
@jelhan
Copy link
Contributor Author

jelhan commented Jul 14, 2018

This PR now contains also a fix. I'm not so used to setUnknownProperty and documentation is not that good. Please pay attention that that one on review.

Copy link
Collaborator

@snewcomer snewcomer left a comment

Choose a reason for hiding this comment

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

Really nice work + tests!!!

// ember's set method does not handle undefined values correctly in older versions
// https://github.com/emberjs/ember.js/issues/14270
if (
acc.hasOwnProperty(currentKey) ||
Copy link
Collaborator

Choose a reason for hiding this comment

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

@jelhan Want to make sure of your intention - should this be && or ||?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's by intention. Maybe it would be easier to read the other way around: setUnknownProperty should only be used if it exists and if the property is not declared on object.

Copy link
Collaborator

@snewcomer snewcomer Jul 28, 2018

Choose a reason for hiding this comment

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

I think this polyfill for set is a-ok. Nice work! Just wanted to make sure.

@snewcomer snewcomer merged commit e6e8cd1 into poteto:master Jul 28, 2018
@jelhan
Copy link
Contributor Author

jelhan commented Jul 28, 2018

@snewcomer Thanks for merging. Could you please ping me after next release? Will update adopted-ember-addons/ember-changeset#191 afterwards.

jelhan added a commit to jelhan/ember-changeset that referenced this pull request Jul 28, 2018
alexlafroscia added a commit to alexlafroscia/ember-deep-set that referenced this pull request Jun 16, 2020
This workaround was added to handle an issue in `Ember.set`

poteto#14

This original problem has long been resolved in Ember. _Not_ calling
`set` now causes some issues with Ember 3.13+, as properties on the
original object either need to be `@tracked` _or_ be updated using
`set`, the later of which makes more sense.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants