Skip to content

Commit

Permalink
feat(debug): replace DebugElement with new Debug DOM
Browse files Browse the repository at this point in the history
Now, using `ng.probe(element)` in the browser console returns
a DebugElement when in dev mode.

`ComponentFixture#debugElement` also returns a new DebugElement.

Breaking Change:

This is a breaking change for unit tests. The API for the DebugElement
has changed. Now, there is a DebugElement or DebugNode for every node
in the DOM, not only nodes with an ElementRef. `componentViewChildren` is
removed, and `childNodes` is a list of ElementNodes corresponding to every
child in the DOM. `query` no longer takes a scope parameter, since
the entire rendered DOM is included in the `childNodes`.

Before:

```
componentFixture.debugElement.componentViewChildren[0];
```

After
```
// Depending on the DOM structure of your component, the
// index may have changed or the first component child
// may be a sub-child.
componentFixture.debugElement.children[0];
```

Before:

```
debugElement.query(By.css('div'), Scope.all());
```

After:

```
debugElement.query(By.css('div'));
```

Before:

```
componentFixture.debugElement.elementRef;
```

After:

```
componentFixture.elementRef;
```
  • Loading branch information
juliemr authored and alexeagle committed Jan 29, 2016
1 parent ae7d2ab commit e1bf3d3
Show file tree
Hide file tree
Showing 45 changed files with 1,233 additions and 1,210 deletions.
2 changes: 1 addition & 1 deletion modules/angular2/core.dart
Expand Up @@ -15,7 +15,7 @@ export './src/core/application_tokens.dart' show APP_ID,
export './src/core/zone.dart';
export './src/core/render.dart';
export './src/core/linker.dart';
export './src/core/debug/debug_element.dart' show DebugElement,
export './src/core/debug/debug_node.dart' show DebugElement,
Scope,
inspectElement,
asNativeElements;
Expand Down
7 changes: 1 addition & 6 deletions modules/angular2/core.ts
Expand Up @@ -20,12 +20,7 @@ export {
export * from './src/core/zone';
export * from './src/core/render';
export * from './src/core/linker';
export {
DebugElement,
Scope,
inspectElement,
asNativeElements
} from './src/core/debug/debug_element';
export {DebugElement, asNativeElements} from './src/core/debug/debug_node';
export * from './src/core/testability/testability';
export * from './src/core/change_detection';
export * from './src/core/platform_directives_and_pipes';
Expand Down
@@ -1,16 +1,8 @@
import {DebugElement, Scope} from 'angular2/core';
import {DebugElement} from 'angular2/core';

var debugElement: DebugElement;
var predicate;

// #docregion scope_all
debugElement.query(predicate, Scope.all);
// #enddocregion

// #docregion scope_light
debugElement.query(predicate, Scope.light);
// #enddocregion

// #docregion scope_view
debugElement.query(predicate, Scope.view);
debugElement.query(predicate);
// #enddocregion
8 changes: 4 additions & 4 deletions modules/angular2/examples/platform/dom/debug/ts/by/by.ts
@@ -1,17 +1,17 @@
import {By} from 'angular2/platform/browser';
import {DebugElement, Scope} from 'angular2/core';
import {DebugElement} from 'angular2/core';

var debugElement: DebugElement;
class MyDirective {}

// #docregion by_all
debugElement.query(By.all(), Scope.all);
debugElement.query(By.all());
// #enddocregion

// #docregion by_css
debugElement.query(By.css('[attribute]'), Scope.all);
debugElement.query(By.css('[attribute]'));
// #enddocregion

// #docregion by_directive
debugElement.query(By.directive(MyDirective), Scope.all);
debugElement.query(By.directive(MyDirective));
// #enddocregion
2 changes: 1 addition & 1 deletion modules/angular2/platform/browser.ts
@@ -1,8 +1,8 @@
export {AngularEntrypoint} from 'angular2/src/core/angular_entrypoint';
export {
BROWSER_PROVIDERS,
ELEMENT_PROBE_BINDINGS,
ELEMENT_PROBE_PROVIDERS,
ELEMENT_PROBE_PROVIDERS_PROD_MODE,
inspectNativeElement,
BrowserDomAdapter,
By,
Expand Down
2 changes: 1 addition & 1 deletion modules/angular2/platform/browser_static.ts
@@ -1,8 +1,8 @@
export {AngularEntrypoint} from 'angular2/src/core/angular_entrypoint';
export {
BROWSER_PROVIDERS,
ELEMENT_PROBE_BINDINGS,
ELEMENT_PROBE_PROVIDERS,
ELEMENT_PROBE_PROVIDERS_PROD_MODE,
inspectNativeElement,
BrowserDomAdapter,
By,
Expand Down
2 changes: 1 addition & 1 deletion modules/angular2/platform/common_dom.ts
Expand Up @@ -12,4 +12,4 @@ export {
EventManagerPlugin
} from 'angular2/src/platform/dom/events/event_manager';
export * from 'angular2/src/platform/dom/debug/by';
export * from 'angular2/src/platform/dom/debug/debug_element_view_listener';
export * from 'angular2/src/platform/dom/debug/ng_probe';
2 changes: 0 additions & 2 deletions modules/angular2/src/core/application_common_providers.ts
Expand Up @@ -15,7 +15,6 @@ import {ResolvedMetadataCache} from 'angular2/src/core/linker/resolved_metadata_
import {AppViewManager} from './linker/view_manager';
import {AppViewManager_} from "./linker/view_manager";
import {ViewResolver} from './linker/view_resolver';
import {AppViewListener} from './linker/view_listener';
import {DirectiveResolver} from './linker/directive_resolver';
import {PipeResolver} from './linker/pipe_resolver';
import {Compiler} from './linker/compiler';
Expand All @@ -32,7 +31,6 @@ export const APPLICATION_COMMON_PROVIDERS: Array<Type | Provider | any[]> = CONS
APP_ID_RANDOM_PROVIDER,
ResolvedMetadataCache,
new Provider(AppViewManager, {useClass: AppViewManager_}),
AppViewListener,
ViewResolver,
new Provider(IterableDiffers, {useValue: defaultIterableDiffers}),
new Provider(KeyValueDiffers, {useValue: defaultKeyValueDiffers}),
Expand Down
248 changes: 0 additions & 248 deletions modules/angular2/src/core/debug/debug_element.ts

This file was deleted.

0 comments on commit e1bf3d3

Please sign in to comment.