This appears to be a regression issue/breaking change in knockoutjs 3.5.1 when binding observables.
When attempting to call applyBindings on an observable we get the following error:
Uncaught Error: Unable to process binding "value: function(){return myObj.GeneralComment }"
Message: Browser doesn't support addEventListener or attachEvent
Here is a simplified version of the code which replicates the issue we're facing after upgrading to v3.5.1, I have included v3.4.2 as a comment so you can see this was previously working
Jsitor
regression issue/breaking change in knockoutjs 3.5.1 when binding observables.
When attempting to call applyBindings on an observable...
The problem you are reporting is not really due to a change when binding observables per se, and in your sample you are not calling applyBindings
using an observable.
Instead, the problem is due to how the valueUpdate
binding processes the propertychange
event.
Prior to 3.5.0 ko.utils.registerEventHandler
used addEventListener
in non-IE browsers. Starting with 3.5.0, ko.utils.registerEventHandler
no longer calls addEventListener
in non-IE browsers and instead errors with the message you reported.
Sample using 3.4.2
Sample using 3.5.1
It appears the change happened in 11e3cb9
Thank you for the response, is this an intended regression impact of 3.5.0? If so, is there a work around other than removing the propertychange
event?
I doubt it is intended that using propertychange
in non-IE browsers should fail the way it currently fails, i.e. it is likely a bug.
To avoid the bug, you would likely need to stop using the propertychange
in knockout bindings, e.g. valueUpdate
and event
bindings. Whether there is a workaround not using valueUpdate
with propertychange
is determined by your particular scenario and use case.
Unfortunately this doesn't appear to be the only problem, in production code removing the propertychange
event does not resolve this error in chrome. Looks like jQuery is also playing a part in this.
Note:
To avoid the bug, you would likely need to stop using the propertychange in knockout bindings, e.g. valueUpdate and event bindings.
Please provide a minimal sample that demonstrates the problem.
Yeah working on it at the moment, as you mentioned there is still likely a bug/breaking change related to the propertychange
event binding that should be addressed
Yes, as I stated above, to avoid the bug you need to stop using propertychange
in all knockout bindings. Internally (in knockout) it boils down to the same bug.
I think we can just remove that exception.
I think that is not correct/sufficient - ko.utils.registerEventHandler
for propertychange
in a non-IE browser (well, a browser w/ DOM elements w/out an attachEvent
method) will not do the correct thing.
My change causes the propertychange
event to be ignored in browsers that don't include attachEvent
.
I understand that. What I didn't understand was that propertychange
was an IE-only event and thus could/should not be registered in non-IE browsers.