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

Unified Diff: third_party/pkg/angular/lib/introspection_js.dart

Issue 257423008: Update all Angular libs (run update_all.sh). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 | « third_party/pkg/angular/lib/introspection.dart ('k') | third_party/pkg/angular/lib/metadata.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/pkg/angular/lib/introspection_js.dart
diff --git a/third_party/pkg/angular/lib/introspection_js.dart b/third_party/pkg/angular/lib/introspection_js.dart
new file mode 100644
index 0000000000000000000000000000000000000000..5ea3be26888d22f015775a5f768983d90bab2704
--- /dev/null
+++ b/third_party/pkg/angular/lib/introspection_js.dart
@@ -0,0 +1,57 @@
+library angular.introspection_expando;
+
+import 'dart:html' as dom;
+import 'dart:js' as js;
+
+import 'package:di/di.dart';
+import 'package:angular/introspection.dart';
+import 'package:angular/core/module_internal.dart';
+import 'package:angular/core_dom/module_internal.dart';
+
+/**
+ * A global write only variable which keeps track of objects attached to the
+ * elements. This is useful for debugging AngularDart application from the
+ * browser's REPL.
+ */
+var elementExpando = new Expando('element');
+
+publishToJavaScript() {
+ js.context
+ ..['ngProbe'] = new js.JsFunction.withThis((_, dom.Node node) => _jsProbe(ngProbe(node)))
+ ..['ngInjector'] = new js.JsFunction.withThis((_, dom.Node node) => _jsInjector(ngInjector(node)))
+ ..['ngScope'] = new js.JsFunction.withThis((_, dom.Node node) => _jsScope(ngScope(node), ngProbe(node).injector.get(ScopeStatsConfig)))
+ ..['ngQuery'] = new js.JsFunction.withThis((_, dom.Node node, String selector, [String containsText]) =>
+ new js.JsArray.from(ngQuery(node, selector, containsText)));
+}
+
+js.JsObject _jsProbe(ElementProbe probe) {
+ return new js.JsObject.jsify({
+ "element": probe.element,
+ "injector": _jsInjector(probe.injector),
+ "scope": _jsScope(probe.scope, probe.injector.get(ScopeStatsConfig)),
+ "directives": probe.directives.map((directive) => _jsDirective(directive))
+ })..['_dart_'] = probe;
+}
+
+js.JsObject _jsInjector(Injector injector) =>
+new js.JsObject.jsify({"get": injector.get})..['_dart_'] = injector;
+
+js.JsObject _jsScope(Scope scope, ScopeStatsConfig config) {
+ return new js.JsObject.jsify({
+ "apply": scope.apply,
+ "broadcast": scope.broadcast,
+ "context": scope.context,
+ "destroy": scope.destroy,
+ "digest": scope.rootScope.digest,
+ "emit": scope.emit,
+ "flush": scope.rootScope.flush,
+ "get": (name) => scope.context[name],
+ "isAttached": scope.isAttached,
+ "isDestroyed": scope.isDestroyed,
+ "set": (name, value) => scope.context[name] = value,
+ "scopeStatsEnable": () => config.emit = true,
+ "scopeStatsDisable": () => config.emit = false
+ })..['_dart_'] = scope;
+}
+
+_jsDirective(directive) => directive;
« no previous file with comments | « third_party/pkg/angular/lib/introspection.dart ('k') | third_party/pkg/angular/lib/metadata.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698