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

Unified Diff: frog/leg/lib/js_helper.dart

Issue 9618053: Introduce the TYPEDEF element, and use it in order to catch passing closures to the DOM. I make the… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: frog/leg/lib/js_helper.dart
===================================================================
--- frog/leg/lib/js_helper.dart (revision 5070)
+++ frog/leg/lib/js_helper.dart (working copy)
@@ -1305,6 +1305,27 @@
return ex;
}
+callClosure0(closure) => closure();
+callClosure1(closure, arg1) => closure(arg1);
+callClosure2(closure, arg1, arg2) => closure(arg1, arg2);
+
+convertDartClosureToJS(closure) {
+ return JS("var", @"""function() {
+ var dartClosure = $0;
+ switch (arguments.length) {
+ case 0: return $1(dartClosure);
+ case 1: return $2(dartClosure, arguments[0]);
+ case 2: return $3(dartClosure, arguments[0], arguments[1]);
+ default:
+ throw new Error('Unsupported number of arguments for wrapped closure');
+ }
+ }""",
+ closure,
+ callClosure0,
+ callClosure1,
+ callClosure2);
+}
+
class StackTrace {
var stack;
StackTrace(this.stack);

Powered by Google App Engine
This is Rietveld 408576698