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: server-side rendering errors in linear progress and slider #5792

Merged
merged 1 commit into from
Apr 9, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 5 additions & 2 deletions packages/mdc-linear-progress/foundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,11 @@ export class MDCLinearProgressFoundation extends

private setPrimaryBarProgress_(progressValue: number) {
const value = `scaleX(${progressValue})`;
this.adapter_.setPrimaryBarStyle(
getCorrectPropertyName(window, 'transform'), value);

// Accessing `window` without a `typeof` check will throw on Node environments.
const transformProp = typeof window !== 'undefined' ?
getCorrectPropertyName(window, 'transform') : 'transform';
this.adapter_.setPrimaryBarStyle(transformProp, value);
}

private setBufferBarProgress_(progressValue: number) {
Expand Down
6 changes: 4 additions & 2 deletions packages/mdc-slider/foundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,9 +496,11 @@ export class MDCSliderFoundation extends MDCFoundation<MDCSliderAdapter> {
translatePx = this.rect_.width - translatePx;
}

const transformProp = getCorrectPropertyName(window, 'transform');
// Accessing `window` without a `typeof` check will throw on Node environments.
const hasWindow = typeof window !== 'undefined';
const transformProp = hasWindow ? getCorrectPropertyName(window, 'transform') : 'transform';
const transitionendEvtName =
getCorrectEventName(window, 'transitionend') as EventType;
hasWindow ? getCorrectEventName(window, 'transitionend') as EventType : 'transitionend';

if (this.inTransit_) {
const onTransitionEnd = () => {
Expand Down