Skip to content
This repository has been archived by the owner on Sep 16, 2022. It is now read-only.

Commit

Permalink
test(Goldens): Show some deficiencies in DirectiveChangeDetector to b…
Browse files Browse the repository at this point in the history
…e improved.

* `@HostListener()`s are not hoisted.
* Life-cycle events are not hoisted.

Instead of removing this class, we should improve it based on my findings.

PiperOrigin-RevId: 246920969
  • Loading branch information
matanlurey authored and alorenzen committed May 7, 2019
1 parent bbf1f7d commit 7a7a32a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
13 changes: 12 additions & 1 deletion _goldens/test/_files/directives/directive_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import 'package:angular/angular.dart';
@Directive(
selector: '[some-child-directive]',
)
class ChildDirective {
class ChildDirective implements OnInit, OnDestroy, AfterChanges {
Element element;

// ignore: deprecated_member_use
ElementRef elementRef;

ChildDirective(this.element, this.elementRef);

StreamController _triggerController;
Expand Down Expand Up @@ -53,6 +55,15 @@ class ChildDirective {

@HostBinding('class.is-disabled')
bool get disabled => false;

@override
void ngOnInit() {}

@override
void ngOnDestroy() {}

@override
void ngAfterChanges() {}
}

@Directive(
Expand Down
15 changes: 15 additions & 0 deletions _goldens/test/_files/directives/directive_wrapper.template.golden
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,29 @@ class ViewTestFooComponent0 extends AppView<import1.TestFooComponent> {
@override
void detectChangesInternal() {
final _ctx = ctx;
bool changed = false;
bool firstCheck = (this.cdState == 0);
changed = false;
final currVal_0 = _ctx.rowIndex;
if (import11.checkBinding(_expr_0, currVal_0)) {
_ChildDirective_0_5.instance.gridRow = currVal_0;
changed = true;
_expr_0 = currVal_0;
}
if (changed) {
_ChildDirective_0_5.instance.ngAfterChanges();
}
if (((!import11.AppViewUtils.throwOnChanges) && firstCheck)) {
_ChildDirective_0_5.instance.ngOnInit();
}
_ChildDirective_0_5.detectHostChanges(this, _el_0);
}

@override
void destroyInternal() {
_ChildDirective_0_5.instance.ngOnDestroy();
}

@override
void initComponentStyles() {
var styles = _componentStyles;
Expand Down

0 comments on commit 7a7a32a

Please sign in to comment.