ember-inspector icon indicating copy to clipboard operation
ember-inspector copied to clipboard

Inspector modifies Changeset

Open basz opened this issue 5 years ago • 6 comments

Not sure if this really is a bug or an unwanted side effect...

When I create a changeset from an ember-data model and open the ember-inspector tab, two properties are created in the changes attribute of the changeset. That means the changeset state (pristine) is changed just by inspecting the ember application... This continues to be true (even after reloading) until I *close( the console window (simply opening a different tab then the ember-inspector will not help)

I suspect this is because ember-data inspects the models and adds some private utility methods and that doesn't play well with the changeset idea...

To Reproduce Create an changeset from an e-d model.

model() {
   return this.store.findRecord('model', id).then(model => new Changeset(model));
}

Add something like this to the template

<pre class="small">
    {{if this.model.isPristine "pristine" "dirty"}}
    {{json this.model.changes}}
</pre>

Expected behavior The rendered output should be:

pristine        []

But as soon as you open the ember-inspector it becomes;

dirty        [
  {
    "key": "_oldWillDestroy",
    "value": "function superWrapper() {\n      var orig = this._super;\n      this._super = superFunc;\n      var ret = func.apply(this, arguments);\n      this._super = orig;\n      return ret;\n    }"
  },
  {
    "key": "willDestroy",
    "value": "function superWrapper() {\n      var orig = this._super;\n      this._super = superFunc;\n      var ret = func.apply(this, arguments);\n      this._super = orig;\n      return ret;\n    }"
  }
]   

Environment ember-inspector: 4.1.0 ember: 3.16.8 ember-data: 3.16.6 ember-changeset: 3.4.0,

Chrome

basz avatar May 24 '20 11:05 basz

@basz this is due to the Proxy#set trap. Let's discuss over in e-c!

snewcomer avatar May 24 '20 13:05 snewcomer

@snewcomer I am having this same issue, unfortunately. If you could kindly point me to the resolution (potentially linked in discord?), I would be greatly appreciative!

I am using v4.4.1 of the inspector, and am using the latest stable ember-changeset on an Ember 3.27 app. Thanks!

tzellman avatar Jun 28 '21 21:06 tzellman

I've also got a very similar issue on 3.26.1, took a long time to debug it!

wynnerd avatar Sep 07 '21 10:09 wynnerd

@snewcomer is this still an issue?

RobbieTheWagner avatar Dec 15 '21 19:12 RobbieTheWagner

Still happens on ember-data 3.28.10 and ember-inspector 4.5.11

close dev tools, refresh page, open dev tools. changeset is pristine. click on Ember tab. changeset dirty

Peek 2022-05-26 12-56

Techn1x avatar May 26 '22 02:05 Techn1x

@snewcomer any ideas on how we could fix this?

RobbieTheWagner avatar Jun 22 '22 14:06 RobbieTheWagner