| OLD | NEW |
| 1 part of angular; | 1 part of angular; |
| 2 | 2 |
| 3 /** | 3 /** |
| 4 * A global write only variable which keeps track of objects attached to the ele
ments. | 4 * A global write only variable which keeps track of objects attached to the ele
ments. |
| 5 * This is usefull for debugging AngularDart application from the browser's REPL
. | 5 * This is usefull for debugging AngularDart application from the browser's REPL
. |
| 6 */ | 6 */ |
| 7 Expando _elementExpando = new Expando('element'); | 7 Expando _elementExpando = new Expando('element'); |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Return the closest [ElementProbe] object for a given [Element]. | 10 * Return the closest [ElementProbe] object for a given [Element]. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 * **NOTE**: This global method is here to make it easier to debug Angular appli
cation from | 39 * **NOTE**: This global method is here to make it easier to debug Angular appli
cation from |
| 40 * the browser's REPL, unit or end-to-end tests. The function is not intended to
be called | 40 * the browser's REPL, unit or end-to-end tests. The function is not intended to
be called |
| 41 * from Angular application. | 41 * from Angular application. |
| 42 */ | 42 */ |
| 43 Scope ngScope(dom.Node node) => ngProbe(node).scope; | 43 Scope ngScope(dom.Node node) => ngProbe(node).scope; |
| 44 | 44 |
| 45 | 45 |
| 46 List<dom.Element> ngQuery(dom.Node element, String selector, [String containsTex
t]) { | 46 List<dom.Element> ngQuery(dom.Node element, String selector, [String containsTex
t]) { |
| 47 var list = []; | 47 var list = []; |
| 48 var children = [element]; | 48 var children = [element]; |
| 49 if ((element is dom.Element) && element.shadowRoot != null) { |
| 50 children.add(element.shadowRoot); |
| 51 } |
| 49 while (!children.isEmpty) { | 52 while (!children.isEmpty) { |
| 50 var child = children.removeAt(0); | 53 var child = children.removeAt(0); |
| 51 child.querySelectorAll(selector).forEach((e) { | 54 child.querySelectorAll(selector).forEach((e) { |
| 52 if (containsText == null || e.text.contains(containsText)) list.add(e); | 55 if (containsText == null || e.text.contains(containsText)) list.add(e); |
| 53 }); | 56 }); |
| 54 child.querySelectorAll('*').forEach((e) { | 57 child.querySelectorAll('*').forEach((e) { |
| 55 if (e.shadowRoot != null) children.add(e.shadowRoot); | 58 if (e.shadowRoot != null) children.add(e.shadowRoot); |
| 56 }); | 59 }); |
| 57 } | 60 } |
| 58 return list; | 61 return list; |
| 59 } | 62 } |
| 60 | 63 |
| 61 /** | 64 /** |
| 62 * Return a List of directive controllers associated with a current [Element]. | 65 * Return a List of directive controllers associated with a current [Element]. |
| 63 * | 66 * |
| 64 * **NOTE**: This global method is here to make it easier to debug Angular appli
cation from | 67 * **NOTE**: This global method is here to make it easier to debug Angular appli
cation from |
| 65 * the browser's REPL, unit or end-to-end tests. The function is not intended to
be called | 68 * the browser's REPL, unit or end-to-end tests. The function is not intended to
be called |
| 66 * from Angular application. | 69 * from Angular application. |
| 67 */ | 70 */ |
| 68 List<Object> ngDirectives(dom.Node node) { | 71 List<Object> ngDirectives(dom.Node node) { |
| 69 ElementProbe probe = _elementExpando[node]; | 72 ElementProbe probe = _elementExpando[node]; |
| 70 return probe == null ? [] : probe.directives; | 73 return probe == null ? [] : probe.directives; |
| 71 } | 74 } |
| 72 | 75 |
| 73 _publishToJavaScript() { | 76 _publishToJavaScript() { |
| 74 js.context.ngProbe = (dom.Node node) => _jsProbe(ngProbe(node)); | 77 js.context['ngProbe'] = (dom.Node node) => _jsProbe(ngProbe(node)); |
| 75 js.context.ngInjector = (dom.Node node) => _jsInjector(ngInjector(node)); | 78 js.context['ngInjector'] = (dom.Node node) => _jsInjector(ngInjector(node)); |
| 76 js.context.ngScope = (dom.Node node) => _jsScope(ngScope(node)); | 79 js.context['ngScope'] = (dom.Node node) => _jsScope(ngScope(node)); |
| 77 js.context.ngQuery = (dom.Node node, String selector, [String containsText]) =
> | 80 js.context['ngQuery'] = (dom.Node node, String selector, [String containsText]
) => |
| 78 new JsArray.from(ngQuery(node, selector, containsText)); | 81 new js.JsArray.from(ngQuery(node, selector, containsText)); |
| 79 } | 82 } |
| 80 | 83 |
| 81 JsObject _jsProbe(ElementProbe probe) { | 84 js.JsObject _jsProbe(ElementProbe probe) { |
| 82 return new JsObject.jsify({ | 85 return new js.JsObject.jsify({ |
| 83 "element": probe.element, | 86 "element": probe.element, |
| 84 "injector": _jsInjector(probe.injector), | 87 "injector": _jsInjector(probe.injector), |
| 85 "scope": _jsScope(probe.scope), | 88 "scope": _jsScope(probe.scope), |
| 86 "directives": probe.directives.map((directive) => _jsDirective(directive)) | 89 "directives": probe.directives.map((directive) => _jsDirective(directive)) |
| 87 })..['_dart_'] = probe; | 90 })..['_dart_'] = probe; |
| 88 } | 91 } |
| 89 | 92 |
| 90 JsObject _jsInjector(Injector injector) { | 93 js.JsObject _jsInjector(Injector injector) { |
| 91 return new JsObject.jsify({ | 94 return new js.JsObject.jsify({ |
| 92 "get": injector.get | 95 "get": injector.get |
| 93 })..['_dart_'] = injector; | 96 })..['_dart_'] = injector; |
| 94 } | 97 } |
| 95 | 98 |
| 96 JsObject _jsScope(Scope scope) { | 99 js.JsObject _jsScope(Scope scope) { |
| 97 return new JsObject.jsify({ | 100 return new js.JsObject.jsify({ |
| 98 "\$apply": scope.$apply, | 101 "\$apply": scope.$apply, |
| 99 "\$digest": scope.$digest, | 102 "\$digest": scope.$digest, |
| 100 "get": (name) => scope[name], | 103 "get": (name) => scope[name], |
| 101 "set": (name, value) => scope[name] = value | 104 "set": (name, value) => scope[name] = value |
| 102 })..['_dart_'] = scope; | 105 })..['_dart_'] = scope; |
| 103 } | 106 } |
| 104 | 107 |
| 105 _jsDirective(directive) => directive; | 108 _jsDirective(directive) => directive; |
| OLD | NEW |