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

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

Issue 1058283006: Update pubspecs and dependencies to get pkgbuild tests working. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 part of angular;
2
3 /**
4 * A global write only variable which keeps track of objects attached to the
5 * elements. This is useful for debugging AngularDart application from the
6 * browser's REPL.
7 */
8 var _elementExpando = new Expando('element');
9
10 /**
11 * Return the closest [ElementProbe] object for a given [Element].
12 *
13 * NOTE: This global method is here to make it easier to debug Angular
14 * application from the browser's REPL, unit or end-to-end tests. The
15 * function is not intended to be called from Angular application.
16 */
17 ElementProbe ngProbe(dom.Node node) {
18 while(node != null) {
19 var probe = _elementExpando[node];
20 if (probe != null) return probe;
21 node = node.parent;
22 }
23 return null;
24 }
25
26
27 /**
28 * Return the [Injector] associated with a current [Element].
29 *
30 * **NOTE**: This global method is here to make it easier to debug Angular
31 * application from the browser's REPL, unit or end-to-end tests. The function
32 * is not intended to be called from Angular application.
33 */
34 Injector ngInjector(dom.Node node) => ngProbe(node).injector;
35
36
37 /**
38 * Return the [Scope] associated with a current [Element].
39 *
40 * **NOTE**: This global method is here to make it easier to debug Angular
41 * application from the browser's REPL, unit or end-to-end tests. The function
42 * is not intended to be called from Angular application.
43 */
44 Scope ngScope(dom.Node node) => ngProbe(node).scope;
45
46
47 List<dom.Element> ngQuery(dom.Node element, String selector,
48 [String containsText]) {
49 var list = [];
50 var children = [element];
51 if ((element is dom.Element) && element.shadowRoot != null) {
52 children.add(element.shadowRoot);
53 }
54 while (!children.isEmpty) {
55 var child = children.removeAt(0);
56 child.querySelectorAll(selector).forEach((e) {
57 if (containsText == null || e.text.contains(containsText)) list.add(e);
58 });
59 child.querySelectorAll('*').forEach((e) {
60 if (e.shadowRoot != null) children.add(e.shadowRoot);
61 });
62 }
63 return list;
64 }
65
66 /**
67 * Return a List of directive controllers associated with a current [Element].
68 *
69 * **NOTE**: This global method is here to make it easier to debug Angular
70 * application from the browser's REPL, unit or end-to-end tests. The function
71 * is not intended to be called from Angular application.
72 */
73 List<Object> ngDirectives(dom.Node node) {
74 ElementProbe probe = _elementExpando[node];
75 return probe == null ? [] : probe.directives;
76 }
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/filter/uppercase.dart ('k') | third_party/pkg/angular/lib/mock/debug.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698