Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit 244e62c

Browse files
authored
fix(ripple): Throws exception with Ivy (#2116)
closes #2110
1 parent 18d3e37 commit 244e62c

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

packages/ripple/ripple.ts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {AfterViewInit, Directive, ElementRef, Input, OnDestroy} from '@angular/core';
1+
import {AfterViewInit, Directive, ElementRef, Input, OnChanges, OnDestroy, SimpleChanges} from '@angular/core';
22
import {coerceBooleanProperty} from '@angular/cdk/coercion';
33
import {supportsPassiveEventListeners} from '@angular/cdk/platform';
44

@@ -10,7 +10,7 @@ import {MDCRippleFoundation, MDCRippleAdapter} from '@material/ripple';
1010
selector: '[mdcRipple], mdc-ripple',
1111
providers: [MdcRipple],
1212
})
13-
export class MdcRippleDirective implements AfterViewInit, OnDestroy, MDCRippleCapableSurface {
13+
export class MdcRippleDirective implements AfterViewInit, OnChanges, OnDestroy, MDCRippleCapableSurface {
1414
_root!: Element;
1515

1616
@Input()
@@ -29,11 +29,6 @@ export class MdcRippleDirective implements AfterViewInit, OnDestroy, MDCRippleCa
2929
}
3030
set primary(value: boolean) {
3131
this._primary = coerceBooleanProperty(value);
32-
if (this._primary) {
33-
this.attachTo.classList.add('mdc-ripple-surface--primary');
34-
} else {
35-
this.attachTo.classList.remove('mdc-ripple-surface--primary');
36-
}
3732
}
3833
private _primary = false;
3934

@@ -43,11 +38,6 @@ export class MdcRippleDirective implements AfterViewInit, OnDestroy, MDCRippleCa
4338
}
4439
set secondary(value: boolean) {
4540
this._secondary = coerceBooleanProperty(value);
46-
if (this._secondary) {
47-
this.attachTo.classList.add('mdc-ripple-surface--accent');
48-
} else {
49-
this.attachTo.classList.remove('mdc-ripple-surface--accent');
50-
}
5141
}
5242
private _secondary = false;
5343

@@ -76,6 +66,24 @@ export class MdcRippleDirective implements AfterViewInit, OnDestroy, MDCRippleCa
7666
this._ripple = this._createRipple();
7767
}
7868

69+
ngOnChanges(changes: SimpleChanges) {
70+
if (changes['primary'] && this.attachTo) {
71+
if (this._primary) {
72+
this.attachTo.classList.add('mdc-ripple-surface--primary');
73+
} else {
74+
this.attachTo.classList.remove('mdc-ripple-surface--primary');
75+
}
76+
}
77+
78+
if (changes['secondary'] && this.attachTo) {
79+
if (this._secondary) {
80+
this.attachTo.classList.add('mdc-ripple-surface--accent');
81+
} else {
82+
this.attachTo.classList.remove('mdc-ripple-surface--accent');
83+
}
84+
}
85+
}
86+
7987
ngAfterViewInit(): void {
8088
this._ripple.init();
8189
}

0 commit comments

Comments
 (0)