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

Unified Diff: sdk/lib/_internal/lib/js_helper.dart

Issue 27112002: Make print interceptable. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comment. Created 7 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/lib/js_helper.dart
diff --git a/sdk/lib/_internal/lib/js_helper.dart b/sdk/lib/_internal/lib/js_helper.dart
index e346734f1b13f6f0b4f5e06622b5d618d70c3138..1890de0cb0ff4a2dfcb2c009cf5ecf87a71a066c 100644
--- a/sdk/lib/_internal/lib/js_helper.dart
+++ b/sdk/lib/_internal/lib/js_helper.dart
@@ -281,42 +281,6 @@ class Primitives {
static computeGlobalThis() => JS('', 'function() { return this; }()');
- /**
- * This is the low-level method that is used to implement
- * [print]. It is possible to override this function from JavaScript
- * by defining a function in JavaScript called "dartPrint".
- */
- static void printString(String string) {
ahe 2013/11/04 09:01:19 In the future, do not move dart2js primitives out
- if (JS('bool', r'typeof dartPrint == "function"')) {
- // Support overriding print from JavaScript.
- JS('void', r'dartPrint(#)', string);
- return;
- }
-
- // Inside browser or nodejs.
- if (JS('bool', r'typeof console == "object"') &&
- JS('bool', r'typeof console.log == "function"')) {
- JS('void', r'console.log(#)', string);
- return;
- }
-
- // Don't throw inside IE, the console is only defined if dev tools is open.
- if (JS('bool', r'typeof window == "object"')) {
- return;
- }
-
- // Running in d8, the V8 developer shell, or in Firefox' js-shell.
- if (JS('bool', r'typeof print == "function"')) {
- JS('void', r'print(#)', string);
- return;
- }
-
- // This is somewhat nasty, but we don't want to drag in a bunch of
- // dependencies to handle a situation that cannot happen. So we
- // avoid using Dart [:throw:] and Dart [toString].
- JS('void', 'throw "Unable to print message: " + String(#)', string);
- }
-
static _throwFormatException(String string) {
throw new FormatException(string);
}

Powered by Google App Engine
This is Rietveld 408576698