I'm currently migrating our front-end from an existing application using Backbone.js to Web UI. We deploy each migrated component which means both apps run on the same page until the migration is completed.
It seems that since I updated to 0.5.5.0_r22416 dart2js' JavaScript output behavior changed. The generated output is extending the JavaScript Object with a property called ___dart_dispatch_record_ZxYxX_0_. In this case every JavaScript object contains this property.
There are some cases where this additional property is creating some trouble. Some of the existing JavaScript libraries we use iterate over the JavaScript object properties. Then they also receive the Dart-dispatch-record object, which they don't handle it properly. One example is Backbone iterating over an events object of a view in order to delegate events. see
https://github.com/documentcloud/backbone/blob/master/backbone.js#L1068
Is there an easy way for me to work around this instead of making the whole javascript codebase + libraries more robust?
I added a code example. In the comments you can see the console output from Chrome 26.0.1410.65
<script>
window.someJsObject = {"routeA": "functionA"};
// dart code already loaded and executed
function load() {
// Console output:
// Object {routeA: "functionA", ___dart_dispatch_record_ZxYxX_0_: Object}
// routeA: "functionA"
// __proto__: Object
// ___dart_dispatch_record_ZxYxX_0_: Object
// __defineGetter__: function __defineGetter__() { [native code] }
// …
console.log(window.someJsObject);
// Console output:
// functionA
// Object {i: Interceptor, p: Object, e: null, ___dart_dispatch_record_ZxYxX_0_: Object}
for (var key in someJsObject) {
console.log(someJsObject[key]);
}
}
window.onload = load;
</script>