Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

Commit

Permalink
feat(Scope): Allow turning emission of scope stats from console.
Browse files Browse the repository at this point in the history
To enable emission of ScopeStats from console one can call function `enableScopeStats(Node)`. To disable call function `disableScopeStats(node)`.

Fixes #836

Closes #857
  • Loading branch information
mvuksano authored and mhevery committed Apr 4, 2014
1 parent 8952cbd commit 18ecd95
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/introspection_js.dart
Expand Up @@ -19,7 +19,7 @@ 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)))
..['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)));
}
Expand All @@ -28,15 +28,15 @@ js.JsObject _jsProbe(ElementProbe probe) {
return new js.JsObject.jsify({
"element": probe.element,
"injector": _jsInjector(probe.injector),
"scope": _jsScope(probe.scope),
"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) {
js.JsObject _jsScope(Scope scope, ScopeStatsConfig config) {
return new js.JsObject.jsify({
"apply": scope.apply,
"broadcast": scope.broadcast,
Expand All @@ -48,7 +48,9 @@ js.JsObject _jsScope(Scope scope) {
"get": (name) => scope.context[name],
"isAttached": scope.isAttached,
"isDestroyed": scope.isDestroyed,
"set": (name, value) => scope.context[name] = value
"set": (name, value) => scope.context[name] = value,
"scopeStatsEnable": () => config.emit = true,
"scopeStatsDisable": () => config.emit = false
})..['_dart_'] = scope;
}

Expand Down

0 comments on commit 18ecd95

Please sign in to comment.