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

Unified Diff: sdk/lib/js_util/dartium/js_util_dartium.dart

Issue 3005913003: Revert: Removed Dartium SDK libs (Closed)
Patch Set: Created 3 years, 4 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
« no previous file with comments | « sdk/lib/js/dartium/js_dartium.dart ('k') | sdk/lib/svg/dartium/svg_dartium.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/js_util/dartium/js_util_dartium.dart
diff --git a/sdk/lib/js_util/dartium/js_util_dartium.dart b/sdk/lib/js_util/dartium/js_util_dartium.dart
new file mode 100644
index 0000000000000000000000000000000000000000..ed9f8049243671a385fb0100278b2aab27517606
--- /dev/null
+++ b/sdk/lib/js_util/dartium/js_util_dartium.dart
@@ -0,0 +1,40 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+/// Utility methods to efficiently manipulate typed JSInterop objects in cases
+/// where the name to call is not known at runtime. You should only use these
+/// methods when the same effect cannot be achieved with @JS annotations.
+/// These methods would be extension methods on JSObject if Dart supported
+/// extension methods.
+library dart.js_util;
+
+import 'dart:js';
+
+/// WARNING: performance of this method is much worse than other util
+/// methods in this library. Only use this method as a last resort.
+///
+/// Recursively converts a JSON-like collection of Dart objects to a
+/// collection of JavaScript objects and returns a [JsObject] proxy to it.
+///
+/// [object] must be a [Map] or [Iterable], the contents of which are also
+/// converted. Maps and Iterables are copied to a new JavaScript object.
+/// Primitives and other transferable values are directly converted to their
+/// JavaScript type, and all other objects are proxied.
+jsify(object) {
+ if ((object is! Map) && (object is! Iterable)) {
+ throw new ArgumentError("object must be a Map or Iterable");
+ }
+ return JsNative.jsify(object);
+}
+
+JSObject newObject() => JsNative.newObject();
+
+hasProperty(JSObject o, name) => JsNative.hasProperty(o, name);
+getProperty(JSObject o, name) => JsNative.getProperty(o, name);
+setProperty(JSObject o, name, value) => JsNative.setProperty(o, name, value);
+callMethod(JSObject o, String method, List args) =>
+ JsNative.callMethod(o, method, args);
+instanceof(JSObject o, Function type) => JsNative.instanceof(o, type);
+callConstructor(JSObject constructor, List args) =>
+ JsNative.callConstructor(constructor, args);
« no previous file with comments | « sdk/lib/js/dartium/js_dartium.dart ('k') | sdk/lib/svg/dartium/svg_dartium.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698