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

Side by Side Diff: third_party/pkg/angular/lib/introspection.dart

Issue 256553002: Revert "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, 7 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 | Annotate | Revision Log
OLDNEW
1 part of angular;
2
1 /** 3 /**
2 * Introspection of Elements for debugging and tests. 4 * A global write only variable which keeps track of objects attached to the
3 */ 5 * elements. This is useful for debugging AngularDart application from the
4 library angular.introspection; 6 * browser's REPL.
5 7 */
6 import 'dart:html' as dom; 8 var _elementExpando = new Expando('element');
7 import 'package:di/di.dart';
8 import 'package:angular/introspection_js.dart';
9 import 'package:angular/core/module_internal.dart';
10 import 'package:angular/core_dom/module_internal.dart';
11 9
12 /** 10 /**
13 * Return the closest [ElementProbe] object for a given [Element]. 11 * Return the closest [ElementProbe] object for a given [Element].
14 * 12 *
15 * **NOTE:** This global method is here to make it easier to debug Angular 13 * NOTE: This global method is here to make it easier to debug Angular
16 * application from the browser's REPL, unit or end-to-end tests. The 14 * application from the browser's REPL, unit or end-to-end tests. The
17 * function is not intended to be called from Angular application. 15 * function is not intended to be called from Angular application.
18 */ 16 */
19 ElementProbe ngProbe(dom.Node node) { 17 ElementProbe ngProbe(dom.Node node) {
20 if (node == null) { 18 while(node != null) {
21 throw "ngProbe called without node"; 19 var probe = _elementExpando[node];
22 }
23 var origNode = node;
24 while (node != null) {
25 var probe = elementExpando[node];
26 if (probe != null) return probe; 20 if (probe != null) return probe;
27 node = node.parent; 21 node = node.parent;
28 } 22 }
29 throw "Could not find a probe for [$origNode]"; 23 return null;
30 } 24 }
31 25
32 26
33 /** 27 /**
34 * Return the [Injector] associated with a current [Element]. 28 * Return the [Injector] associated with a current [Element].
35 * 29 *
36 * **NOTE**: This global method is here to make it easier to debug Angular 30 * **NOTE**: This global method is here to make it easier to debug Angular
37 * application from the browser's REPL, unit or end-to-end tests. The function 31 * application from the browser's REPL, unit or end-to-end tests. The function
38 * is not intended to be called from Angular application. 32 * is not intended to be called from Angular application.
39 */ 33 */
(...skipping 30 matching lines...) Expand all
70 } 64 }
71 65
72 /** 66 /**
73 * Return a List of directive controllers associated with a current [Element]. 67 * Return a List of directive controllers associated with a current [Element].
74 * 68 *
75 * **NOTE**: This global method is here to make it easier to debug Angular 69 * **NOTE**: This global method is here to make it easier to debug Angular
76 * application from the browser's REPL, unit or end-to-end tests. The function 70 * application from the browser's REPL, unit or end-to-end tests. The function
77 * is not intended to be called from Angular application. 71 * is not intended to be called from Angular application.
78 */ 72 */
79 List<Object> ngDirectives(dom.Node node) { 73 List<Object> ngDirectives(dom.Node node) {
80 ElementProbe probe = elementExpando[node]; 74 ElementProbe probe = _elementExpando[node];
81 return probe == null ? [] : probe.directives; 75 return probe == null ? [] : probe.directives;
82 } 76 }
83 77
78 _publishToJavaScript() {
79 js.context
80 ..['ngProbe'] = (dom.Node node) => _jsProbe(ngProbe(node))
81 ..['ngInjector'] = (dom.Node node) => _jsInjector(ngInjector(node))
82 ..['ngScope'] = (dom.Node node) => _jsScope(ngScope(node))
83 ..['ngQuery'] = (dom.Node node, String selector, [String containsText]) =>
84 new js.JsArray.from(ngQuery(node, selector, containsText));
85 }
86
87 js.JsObject _jsProbe(ElementProbe probe) {
88 return new js.JsObject.jsify({
89 "element": probe.element,
90 "injector": _jsInjector(probe.injector),
91 "scope": _jsScope(probe.scope),
92 "directives": probe.directives.map((directive) => _jsDirective(directive))
93 })..['_dart_'] = probe;
94 }
95
96 js.JsObject _jsInjector(Injector injector) =>
97 new js.JsObject.jsify({"get": injector.get})..['_dart_'] = injector;
98
99 js.JsObject _jsScope(Scope scope) {
100 return new js.JsObject.jsify({
101 "apply": scope.apply,
102 "digest": scope.rootScope.digest,
103 "flush": scope.rootScope.flush,
104 "context": scope.context,
105 "get": (name) => scope.context[name],
106 "set": (name, value) => scope.context[name] = value
107 })..['_dart_'] = scope;
108 }
109
110 _jsDirective(directive) => directive;
OLDNEW
« no previous file with comments | « third_party/pkg/angular/lib/formatter/uppercase.dart ('k') | third_party/pkg/angular/lib/introspection_js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698