Skip to content

Commit

Permalink
revert fix-infinite-changed-key-loop
Browse files Browse the repository at this point in the history
  • Loading branch information
jakesjews committed May 9, 2017
1 parent 9abdfae commit e3c8b6c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 35 deletions.
30 changes: 0 additions & 30 deletions addon/ext.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import FragmentArray from './array/fragment';
const keys = Object.keys || Ember.keys;
const create = Object.create || Ember.create;
const getOwner = Ember.getOwner;
const assign = Ember.assign;
const typeOf = Ember.typeOf;

let InternalModelPrototype = InternalModel.prototype;
const internalModelExpectsModelName = InternalModelPrototype.hasOwnProperty('modelClass');
Expand Down Expand Up @@ -281,34 +279,6 @@ decorateMethod(InternalModelPrototype, 'adapterDidError', function adapterDidErr
}
});

/**
Ember Data may return false positives when working with fragments,
since our changed keys may be Javascript objects, and equality
between normal Javascript objects cannot be tested with `===`.
@method _changedKeys
@private
*/
decorateMethod(InternalModelPrototype, '_changedKeys', function changedKeysFragments(changedKeys, args) {
let updates = args[0];
let original = assign({}, this._data);
original = assign(original, this._inFlightAttributes);

let i = 0;
while (i < changedKeys.length) {
let changedKey = changedKeys[i];
if (typeOf(original[changedKey]) === 'object' || typeOf(original[changedKey]) === 'array') {
if (JSON.stringify(original[changedKey]) === JSON.stringify(updates[changedKey])) {
changedKeys.splice(i, 1);
continue;
}
}
i += 1;
}

return changedKeys;
});

/**
@class JSONSerializer
@namespace DS
Expand Down
5 changes: 2 additions & 3 deletions addon/states.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import RootState from 'ember-data/-private/system/model/states';

const get = Ember.get;
const create = Object.create || Ember.create;
const assign = Ember.assign;

const didSetProperty = RootState.loaded.saved.didSetProperty;
const propertyWasReset = RootState.loaded.updated.uncommitted.propertyWasReset;
Expand Down Expand Up @@ -169,9 +168,9 @@ export default FragmentRootState;

export function fragmentDidDirty(record, key, fragment) {
if (!get(record, 'isDeleted')) {
// Add the fragment data as a placeholder in the owner record's
// Add the fragment as a placeholder in the owner record's
// `_attributes` hash to indicate it is dirty
record._internalModel._attributes[key] = fragment && assign({}, fragment._data, fragment._attributes);
record._internalModel._attributes[key] = fragment;

record.send('becomeDirty');
}
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/components/alias-component-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Ember from 'ember';
import { moduleForComponent, test } from 'ember-qunit';
import { moduleForComponent, skip } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
import Pretender from 'pretender';
let owner, store, server;
Expand All @@ -19,7 +19,7 @@ moduleForComponent('alias-component', 'Integration | Component | alias component
}
});

test('the adapter can update fragments without infinite loops when CPs are aliased more than once', function(assert) {
skip('the adapter can update fragments without infinite loops when CPs are aliased more than once', function(assert) {
let payloadBefore = {
vehicle: {
id: 1,
Expand Down

0 comments on commit e3c8b6c

Please sign in to comment.