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

Unified Diff: third_party/pkg/angular/lib/mock/probe.dart

Issue 124053002: Adding Angular and dependent packages for testing (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 12 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 side-by-side diff with in-line comments
Download patch
Index: third_party/pkg/angular/lib/mock/probe.dart
diff --git a/third_party/pkg/angular/lib/mock/probe.dart b/third_party/pkg/angular/lib/mock/probe.dart
new file mode 100644
index 0000000000000000000000000000000000000000..b146bf63d5c9d5e72129974395727b59a8278b8b
--- /dev/null
+++ b/third_party/pkg/angular/lib/mock/probe.dart
@@ -0,0 +1,30 @@
+part of angular.mock;
+
+/*
+ * Use Probe directive to capture the Scope, Injector and Element from any DOM
+ * location into root-scope. This is useful for testing to get a hold of
+ * any directive.
+ *
+ * <div some-directive probe="myProbe">..</div>
+ *
+ * rootScope.myProbe.directive(SomeAttrDirective);
+ */
+@NgDirective(selector: '[probe]')
+class Probe implements NgDetachAware {
+ final Scope scope;
+ final Injector injector;
+ final Element element;
+ final NodeAttrs _attrs;
+
+ Probe(this.scope, this.injector, this.element, this._attrs) {
+ scope.$root[_attrs['probe']] = this;
+ }
+
+ detach() => scope.$root[_attrs['probe']] = null;
+
+ /**
+ * Retrieve a Directive at the current element.
+ */
+ directive(Type type) => injector.get(type);
+}
+

Powered by Google App Engine
This is Rietveld 408576698