lolmaus / ember-cli-stained-by-children

Ember CLI addon: a mixin that makes the `isDirty` property of a record respect the dirtiness of its belongsTo/hasMany children
MIT License
25 stars 6 forks source link

clean-embedded-children does not work with 1.0.0-beta.19.1 #10

Open dadamssg opened 9 years ago

dadamssg commented 9 years ago

During the _processChildren function call, child does not have a send function.

    _processChildren: function(callback) {
      this._processRelationshipsOneOrMany(function(child) {
        if ((child == null) || !child.get('isDirty')) {
          return;
        }

        child.send('willCommit'); // <-- problem here
        callback(child);
        child.send('didCommit');

        if (typeof child._cleanChildren === "function") {
          child._cleanChildren();
        }
      });
    },

I get the following stack trace

TypeError: child.send is not a function
    at clean-embedded-children.js:61
    at clean-embedded-children.js:26
    at exports.default._emberMetalMixin.Mixin.create.forEach (ember.debug.js:32996)
    at null.<anonymous> (clean-embedded-children.js:25)
    at clean-embedded-children.js:10
    at ext.js:492
    at Map.forEach.cb (ember.debug.js:16792)
    at OrderedSet.forEach (ember.debug.js:16575)
    at Map.forEach (ember.debug.js:16796)
    at Function.ember$data$lib$system$model$$default.reopenClass.eachRelationship (ext.js:491)
melindaweathers commented 9 years ago

I am seeing a similar problem in beta 19.2 -- there is no error happening, but the child record is still 'isDirty' after it is processed, so clean-embedded-children just silently doesn't work.

The state of the child winds up as "root.loaded.updated.uncommitted"

EDIT: I found a hack to work around this, and it's really a separate issue, so I'll open a separate issue.