These are chat archives for canjs/canjs

5th
Mar 2018
Nico R.
@nriesco
Mar 05 2018 13:51
Hi, I’m having trouble when sorting a DefineList
this is the error:
TypeError: Cannot read property 'Symbol(zone-eventhandler)' of undefined
    at AnchorElement.<anonymous> (/Users/nriesco/git/riescorp/donejs-base/node_modules/can-zone/lib/tasks.js:207:27)
    at AnchorElement.wrappedFn [as removeEventListener] (/Users/nriesco/git/riescorp/donejs-base/node_modules/can-zone/register.js:101:43)
    at AnchorElement.removeEventListener (file:/Users/nriesco/git/riescorp/donejs-base/node_modules/can-util/dom/events/events.js:31:28)
    at AnchorElement.events.removeEventListener (file:/Users/nriesco/git/riescorp/donejs-base/node_modules/can-util/dom/events/make-mutation-event/make-mutation-event.js:90:25)
    at AnchorElement.events.removeEventListener (file:/Users/nriesco/git/riescorp/donejs-base/node_modules/can-util/dom/events/attributes/attributes.js:80:24)
    at AnchorElement.events.removeEventListener (file:/Users/nriesco/git/riescorp/donejs-base/node_modules/can-util/dom/events/make-mutation-event/make-mutation-event.js:90:25)
    at AnchorElement.domEvents.removeEventListener (file:/Users/nriesco/git/riescorp/donejs-base/node_modules/can-util/dom/attr/attr.js:657:32)
    at AnchorElement.removeEventListener (file:/Users/nriesco/git/riescorp/donejs-base/node_modules/can-dom-events/helpers/add-event-compat.js:78:33)
    at AnchorElement.removeEventListener (file:/Users/nriesco/git/riescorp/donejs-base/node_modules/can-dom-events/helpers/add-event-compat.js:78:33)
    at AnchorElement.off (file:/Users/nriesco/git/riescorp/donejs-base/node_modules/can-event/can-event.js:231:22)
It happens sometimes (after reloads, and I need to restart the app to make it work again)
what causes the issue is this: data.sort(sorter);
I simplified sort to avoid errors: var sorter = function(a, b) { return true; };
I even tried using try/catch if (data instanceof DefineList)
Nico R.
@nriesco
Mar 05 2018 14:01
I think is the server side rendering that is failing
Nico R.
@nriesco
Mar 05 2018 14:14
this only affects the initial load, I thought I had a way to sort data after loading, but that seems to be a big splinter left to remove
Nico R.
@nriesco
Mar 05 2018 15:04
It seems to me that there must be a condition where I should not sort, something like if (data instanceof DefineList) data.sort(sorter) so I don’t sort when some criteria is not met. The thing is that not even try/catch will stop it from failling so I really need to know in advance what to verify.
or data.isSortable or DefineList.isSortable(data)