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

[Bug]: overridable mergeDeep to fix null typeof check #563

Merged
merged 8 commits into from
Nov 21, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ import { EmberChangeset, Changeset } from 'ember-changeset';
class MyChangeset extends EmberChangeset {
save() {
super.save(...arguments);
// my other stuff
// do stuff
}
}

Expand Down
7 changes: 4 additions & 3 deletions addon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class EmberChangeset extends BufferedChangeset {
// override base class
// DO NOT override setDeep. Ember.set does not work with Ember.set({}, 'user.name', 'foo');
getDeep = safeGet;
mergeDeep = mergeDeep;

// override base class
safeGet(obj, key) {
Expand Down Expand Up @@ -95,9 +96,9 @@ export class EmberChangeset extends BufferedChangeset {
let content = this[CONTENT];
let changes = this[CHANGES];

let pendingChanges = mergeDeep(Object.create(Object.getPrototypeOf(content)), content, { safeGet, safeSet });
let pendingChanges = this.mergeDeep(Object.create(Object.getPrototypeOf(content)), content, { safeGet, safeSet });

return mergeDeep(pendingChanges, changes, { safeGet, safeSet });
return this.mergeDeep(pendingChanges, changes, { safeGet, safeSet });
}

/**
Expand Down Expand Up @@ -180,7 +181,7 @@ export class EmberChangeset extends BufferedChangeset {

// we want mutation on original object
// @tracked
this[CONTENT] = mergeDeep(content, changes, { safeGet, safeSet });
this[CONTENT] = this.mergeDeep(content, changes, { safeGet, safeSet });
}

this[PREVIOUS_CONTENT] = oldContent;
Expand Down
4 changes: 2 additions & 2 deletions config/ember-try.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ module.exports = async function () {
},
},
{
name: 'ember-release',
name: 'ember-lts-3.20',
npm: {
devDependencies: {
'ember-source': await getChannelURL('release'),
'ember-source': '~3.20.0',
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@
"@glimmer/tracking": "^1.0.1",
"ember-auto-import": "^1.5.2",
"ember-cli-babel": "^7.19.0",
"validated-changeset": "~0.10.0"
"validated-changeset": "~0.10.2"
},
"devDependencies": {
"@ember/optional-features": "^1.0.0",
"babel-eslint": "^10.1.0",
"broccoli-asset-rev": "^3.0.0",
"ember-cli": "~3.21.0",
"ember-cli": "~3.22.0",
"ember-cli-dependency-checker": "^3.1.0",
"ember-cli-htmlbars": "^5.1.2",
"ember-cli-inject-live-reload": "^2.0.1",
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/helpers/changeset-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ module('Integration | Helper | changeset', function (hooks) {
return (isPresent(value) && value.length > 3) || 'too short';
},
};
this.set('dummyModel', { firstName: 'Jim', lastName: 'Bob' });
this.set('dummyModel', { firstName: 'Jimm', lastName: 'Bob' });
this.set('validate', ({ key, newValue }) => {
let validatorFn = validations[key];

Expand Down
Loading