Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(228)

Side by Side Diff: sdk/lib/js/dart2js/js_dart2js.dart

Issue 1412193009: Fix bug in allowInteropCaptureThis that caused JavaScript objects to accidentally be wrapped. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tests/html/js_typed_interop_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * Support for interoperating with JavaScript. 6 * Support for interoperating with JavaScript.
7 * 7 *
8 * This library provides access to JavaScript objects from Dart, allowing 8 * This library provides access to JavaScript objects from Dart, allowing
9 * Dart code to get and set properties, and call methods of JavaScript objects 9 * Dart code to get and set properties, and call methods of JavaScript objects
10 * and invoke JavaScript functions. The library takes care of converting 10 * and invoke JavaScript functions. The library takes care of converting
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 JS('', '#.# = #', ret, DART_CLOSURE_PROPERTY_NAME, f); 697 JS('', '#.# = #', ret, DART_CLOSURE_PROPERTY_NAME, f);
698 JS('', '#.# = #', f, _JS_FUNCTION_PROPERTY_NAME_CAPTURE_THIS, ret); 698 JS('', '#.# = #', f, _JS_FUNCTION_PROPERTY_NAME_CAPTURE_THIS, ret);
699 return ret; 699 return ret;
700 } 700 }
701 701
702 _callDartFunctionFast(callback, List arguments) { 702 _callDartFunctionFast(callback, List arguments) {
703 return Function.apply(callback, arguments); 703 return Function.apply(callback, arguments);
704 } 704 }
705 705
706 _callDartFunctionFastCaptureThis(callback, self, List arguments) { 706 _callDartFunctionFastCaptureThis(callback, self, List arguments) {
707 return _convertToJS(Function.apply(callback, [self]..addAll(arguments))); 707 return Function.apply(callback, [self]..addAll(arguments));
708 } 708 }
709 709
710 Function allowInterop(Function f) { 710 Function allowInterop(Function f) {
711 if (JS('bool', 'typeof(#) == "function"', f)) { 711 if (JS('bool', 'typeof(#) == "function"', f)) {
712 // Already supports interop, just use the existing function. 712 // Already supports interop, just use the existing function.
713 return f; 713 return f;
714 } else { 714 } else {
715 return _convertDartFunctionFast(f); 715 return _convertDartFunctionFast(f);
716 } 716 }
717 } 717 }
718 718
719 Function allowInteropCaptureThis(Function f) { 719 Function allowInteropCaptureThis(Function f) {
720 if (JS('bool', 'typeof(#) == "function"', f)) { 720 if (JS('bool', 'typeof(#) == "function"', f)) {
721 // Behavior when the function is already a JS function is unspecified. 721 // Behavior when the function is already a JS function is unspecified.
722 throw new ArgumentError( 722 throw new ArgumentError(
723 "Function is already a JS function so cannot capture this."); 723 "Function is already a JS function so cannot capture this.");
724 return f; 724 return f;
725 } else { 725 } else {
726 return _convertDartFunctionFastCaptureThis(f); 726 return _convertDartFunctionFastCaptureThis(f);
727 } 727 }
728 } 728 }
OLDNEW
« no previous file with comments | « no previous file | tests/html/js_typed_interop_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698