-
Notifications
You must be signed in to change notification settings - Fork 11
Network storeAs isn't working, Ember lifecycle hook argument deprecation #11
Description
Hi again Suven,
Thanks for making this addon! I'm having fun with it.
I want to add a button to trigger the "fit" action on the network instance, so I set the "storeAs" property in my component's template like so:
{{#visjs-network options=networkOptions storeAs=network}}
{{#each nodes as |node|}}
{{visjs-node nId=node.id label=node.label select=(action "selectNode")}}
{{#if node.parentId}}
{{visjs-edge from=node.id to=node.parentId}}
{{/if}}
{{/each}}
{{/visjs-network}}
I expect to be able to use that property once it's set, in one of my actions. But I didn't get that far. When I reload the page, I get the following errors:
jquery.js:3860 jQuery.Deferred exception: Cannot read property 'newAttrs' of undefined TypeError: Cannot read property 'newAttrs' of undefined
at Class.didUpdateAttrs (http://localhost:4200/assets/vendor.js:127676:19)
at Class.trigger (http://localhost:4200/assets/vendor.js:58373:23)
at Class.superWrapper [as trigger] (http://localhost:4200/assets/vendor.js:56392:22)
at CurlyComponentManager.update (http://localhost:4200/assets/vendor.js:25891:19)
at UpdateComponentOpcode.evaluate (http://localhost:4200/assets/vendor.js:13301:21)
at UpdatingVM.execute (http://localhost:4200/assets/vendor.js:18038:24)
at RenderResult.rerender (http://localhost:4200/assets/vendor.js:18396:16)
at RootState._this.render (http://localhost:4200/assets/vendor.js:30420:25)
at TransactionRunner.runInTransaction (http://localhost:4200/assets/vendor.js:34074:33)
at InteractiveRenderer._renderRoots (http://localhost:4200/assets/vendor.js:30692:81) undefined
jQuery.Deferred.exceptionHook @ jquery.js:3860
process @ jquery.js:3655
setTimeout (async)
(anonymous) @ jquery.js:3689
fire @ jquery.js:3317
fireWith @ jquery.js:3447
fire @ jquery.js:3455
fire @ jquery.js:3317
fireWith @ jquery.js:3447
ready @ jquery.js:3920
completed @ jquery.js:3930
jquery.js:3649 [Violation] 'setTimeout' handler took 201ms
visjs-network.js:79 Uncaught TypeError: Cannot read property 'newAttrs' of undefined
at Class.didUpdateAttrs (visjs-network.js:79)
at Class.trigger (core_view.js:62)
at Class.superWrapper [as trigger] (ember-utils.js:437)
at CurlyComponentManager.update (curly.js:340)
at UpdateComponentOpcode.evaluate (runtime.js:1760)
at UpdatingVM.execute (runtime.js:6497)
at RenderResult.rerender (runtime.js:6855)
at RootState._this.render (renderer.js:69)
at TransactionRunner.runInTransaction (ember-metal.js:826)
at InteractiveRenderer._renderRoots (renderer.js:341)
It turns out this is because Ember deprecated arguments being passed to didUpdateAttrs(). See https://emberjs.com/deprecations/v2.x/#toc_arguments-in-component-lifecycle-hooks
The offending line is here:
ember-cli-visjs/addon/components/visjs-network.js
Lines 76 to 90 in 9fea6ed
| didUpdateAttrs(changes) { | |
| this._super(...arguments); | |
| if (changes.newAttrs.backgroundImage) { | |
| this.setupBackgroundImage(); | |
| } | |
| if (changes.newAttrs.addEdges) { | |
| this.setupAddEdges(); | |
| } | |
| if (changes.newAttrs.options) { | |
| this.setupAddEdges(); | |
| } | |
| }, |
When I comment out those checks, storeAs works without error, but that's not a solution. I tried to convert to old/new checks as suggested in the deprecation info, but when I tried to test with a background image the image would not change when I modified its property.
Would you take a look? Thanks!