| Index: frog/value.dart
|
| diff --git a/frog/value.dart b/frog/value.dart
|
| index bb5ff4ce54ef2c3ecc63d4f970173e077ef6ba76..9d638d23050872ac1d129e02bcdf21e5fb17d5f8 100644
|
| --- a/frog/value.dart
|
| +++ b/frog/value.dart
|
| @@ -195,8 +195,9 @@ class Value {
|
|
|
| /**
|
| * Assign or convert this value to another type.
|
| - * This is used for converting between function types, and inserting type
|
| - * checks when --enable_type_checks is enabled.
|
| + * This is used for converting between function types, inserting type
|
| + * checks when --enable_type_checks is enabled, and wrapping callback
|
| + * functions passed to the dom so we can restore their isolate context.
|
| */
|
| // WARNING: this needs to be kept in sync with needsConversion above.
|
| Value convertTo(MethodGenerator context, Type toType, Node node,
|
| @@ -215,7 +216,11 @@ class Value {
|
| var myCall = type.getCallMethod();
|
| if (myCall == null || myCall.parameters.length != arity) {
|
| final stub = world.functionType.getCallStub(new Arguments.bare(arity));
|
| - return new Value(toType, 'to\$${stub.name}($code)');
|
| + var val = new Value(toType, 'to\$${stub.name}($code)');
|
| + return _isDomCallback(toType) && !_isDomCallback(type) ?
|
| + val._wrapDomCallback(toType, arity) : val;
|
| + } else if (_isDomCallback(toType) && !_isDomCallback(type)) {
|
| + return _wrapDomCallback(toType, arity);
|
| }
|
| }
|
|
|
| @@ -273,6 +278,15 @@ class Value {
|
| }
|
| }
|
|
|
| + bool _isDomCallback(toType) {
|
| + return (toType.definition is FunctionTypeDefinition
|
| + && toType.library == world.dom);
|
| + }
|
| +
|
| + Value _wrapDomCallback(Type toType, int arity) {
|
| + return new Value(toType, '\$wrap_call\$$arity($code)');
|
| + }
|
| +
|
| /**
|
| * Generates a run time type assertion for the given value. This works like
|
| * [instanceOf], but it allows null since Dart types are nullable.
|
|
|