Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ripple): Clean activation timer and css when interrupted (#2460) #2490

Merged
merged 5 commits into from
Apr 3, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/mdc-ripple/foundation.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@ class MDCRippleFoundation extends MDCFoundation {
if (!this.isSupported_()) {
return;
}

if (this.activationTimer_) {
clearTimeout(this.activationTimer_);
this.activationTimer_ = 0;
}

this.deregisterRootHandlers_();
this.deregisterDeactivationHandlers_();

Expand Down
11 changes: 11 additions & 0 deletions test/unit/mdc-ripple/foundation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,17 @@ testFoundation('#destroy removes all CSS variables', ({foundation, adapter, mock
});
});

testFoundation('#destroy clears the activation timer if pending', ({foundation, mockRaf}) => {
foundation.init();
mockRaf.flush();

foundation.activationTimer_ = 1;
foundation.destroy();
mockRaf.flush();

assert.equal(foundation.activationTimer_, 0);
});

testFoundation('#destroy does nothing if CSS custom properties are not supported', ({foundation, adapter, mockRaf}) => {
const isA = td.matchers.isA;
td.when(adapter.browserSupportsCssVars()).thenReturn(false);
Expand Down