| OLD | NEW |
| (Empty) |
| 1 library angular.introspection_expando; | |
| 2 | |
| 3 import 'dart:html' as dom; | |
| 4 import 'dart:js' as js; | |
| 5 | |
| 6 import 'package:di/di.dart'; | |
| 7 import 'package:angular/introspection.dart'; | |
| 8 import 'package:angular/core/module_internal.dart'; | |
| 9 import 'package:angular/core_dom/module_internal.dart'; | |
| 10 | |
| 11 /** | |
| 12 * A global write only variable which keeps track of objects attached to the | |
| 13 * elements. This is useful for debugging AngularDart application from the | |
| 14 * browser's REPL. | |
| 15 */ | |
| 16 var elementExpando = new Expando('element'); | |
| 17 | |
| 18 publishToJavaScript() { | |
| 19 js.context | |
| 20 ..['ngProbe'] = new js.JsFunction.withThis((_, dom.Node node) => _jsProbe(ng
Probe(node))) | |
| 21 ..['ngInjector'] = new js.JsFunction.withThis((_, dom.Node node) => _jsInjec
tor(ngInjector(node))) | |
| 22 ..['ngScope'] = new js.JsFunction.withThis((_, dom.Node node) => _jsScope(ng
Scope(node), ngProbe(node).injector.get(ScopeStatsConfig))) | |
| 23 ..['ngQuery'] = new js.JsFunction.withThis((_, dom.Node node, String selecto
r, [String containsText]) => | |
| 24 new js.JsArray.from(ngQuery(node, selector, containsText))); | |
| 25 } | |
| 26 | |
| 27 js.JsObject _jsProbe(ElementProbe probe) { | |
| 28 return new js.JsObject.jsify({ | |
| 29 "element": probe.element, | |
| 30 "injector": _jsInjector(probe.injector), | |
| 31 "scope": _jsScope(probe.scope, probe.injector.get(ScopeStatsConfig)), | |
| 32 "directives": probe.directives.map((directive) => _jsDirective(directive)) | |
| 33 })..['_dart_'] = probe; | |
| 34 } | |
| 35 | |
| 36 js.JsObject _jsInjector(Injector injector) => | |
| 37 new js.JsObject.jsify({"get": injector.get})..['_dart_'] = injector; | |
| 38 | |
| 39 js.JsObject _jsScope(Scope scope, ScopeStatsConfig config) { | |
| 40 return new js.JsObject.jsify({ | |
| 41 "apply": scope.apply, | |
| 42 "broadcast": scope.broadcast, | |
| 43 "context": scope.context, | |
| 44 "destroy": scope.destroy, | |
| 45 "digest": scope.rootScope.digest, | |
| 46 "emit": scope.emit, | |
| 47 "flush": scope.rootScope.flush, | |
| 48 "get": (name) => scope.context[name], | |
| 49 "isAttached": scope.isAttached, | |
| 50 "isDestroyed": scope.isDestroyed, | |
| 51 "set": (name, value) => scope.context[name] = value, | |
| 52 "scopeStatsEnable": () => config.emit = true, | |
| 53 "scopeStatsDisable": () => config.emit = false | |
| 54 })..['_dart_'] = scope; | |
| 55 } | |
| 56 | |
| 57 _jsDirective(directive) => directive; | |
| OLD | NEW |