Uncaught Error: Assertion Failed: calling set on destroyed object

后端 未结 4 1171
旧巷少年郎
旧巷少年郎 2021-02-05 00:09

working in ember-cli testing. After all tests passed it returns extra two test with errors.

Uncaught Error: Assertion Failed: calling set on destroyed obj

4条回答
  •  长发绾君心
    2021-02-05 00:58

    This is either because in the result of a promise or any other deferred code you do not check the destroy status of an object, or because you didn't teardown something that has been setup and interact with DOM events or anything external to the core of Ember.

    I used to have this especially on some jQuery plugins which I mapped to Ember, and during the tests the plugins were destroying too slowly and I was then either not using a run loop, or not checking the destroyed status of the Ember object I was manipulating.

    You can do so with:

    if ( !(obj.get('isDestroyed') || obj.get('isDestroying')) ) {
      // do your destroying code setting stuff
    }
    

    Also think about destroying any jQuery plugins that might have been initialised in the code of your views (anything setup in didInsertElement should be teardown in willDestroyElement for example).

提交回复
热议问题