Skip to content

fix(material-experimental): better server-side rendering support for progress bar #19036

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

Merged
merged 1 commit into from
Apr 17, 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"@types/youtube": "^0.0.38",
"@webcomponents/custom-elements": "^1.1.0",
"core-js": "^2.6.9",
"material-components-web": "6.0.0-canary.9930d9cc5.0",
"material-components-web": "6.0.0-canary.927fa902c.0",
"rxjs": "^6.5.3",
"systemjs": "0.19.43",
"tslib": "^1.10.0",
Expand Down
1 change: 0 additions & 1 deletion src/material-experimental/mdc-checkbox/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ ng_module(
module_name = "@angular/material-experimental/mdc-checkbox",
deps = [
"//src/cdk/coercion",
"//src/cdk/platform",
"//src/material/checkbox",
"//src/material/core",
"@npm//@angular/animations",
Expand Down
4 changes: 1 addition & 3 deletions src/material-experimental/mdc-checkbox/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion';
import {Platform} from '@angular/cdk/platform';
import {
AfterViewInit,
Attribute,
Expand Down Expand Up @@ -211,7 +210,7 @@ export class MatCheckbox implements AfterViewInit, OnDestroy, ControlValueAccess
private _checkboxAdapter: MDCCheckboxAdapter = {
addClass: (className) => this._setClass(className, true),
removeClass: (className) => this._setClass(className, false),
forceLayout: () => this._platform.isBrowser && this._checkbox.nativeElement.offsetWidth,
forceLayout: () => this._checkbox.nativeElement.offsetWidth,
hasNativeControl: () => !!this._nativeCheckbox,
isAttachedToDOM: () => !!this._checkbox.nativeElement.parentNode,
isChecked: () => this.checked,
Expand All @@ -233,7 +232,6 @@ export class MatCheckbox implements AfterViewInit, OnDestroy, ControlValueAccess

constructor(
private _changeDetectorRef: ChangeDetectorRef,
private _platform: Platform,
@Attribute('tabindex') tabIndex: string,
/**
* @deprecated `_clickAction` parameter to be removed, use
Expand Down
1 change: 0 additions & 1 deletion src/material-experimental/mdc-progress-bar/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ ng_module(
module_name = "@angular/material-experimental/mdc-progress-bar",
deps = [
"//src/cdk/bidi",
"//src/cdk/platform",
"//src/material/core",
"//src/material/progress-bar",
"@npm//@angular/core",
Expand Down
7 changes: 2 additions & 5 deletions src/material-experimental/mdc-progress-bar/progress-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import {MDCLinearProgressAdapter, MDCLinearProgressFoundation} from '@material/l
import {Subscription, fromEvent, Observable} from 'rxjs';
import {filter} from 'rxjs/operators';
import {Directionality} from '@angular/cdk/bidi';
import {Platform} from '@angular/cdk/platform';

// Boilerplate for applying mixins to MatProgressBar.
/** @docs-private */
Expand Down Expand Up @@ -63,7 +62,6 @@ export class MatProgressBar extends _MatProgressBarMixinBase implements AfterVie

constructor(public _elementRef: ElementRef<HTMLElement>,
private _ngZone: NgZone,
private _platform: Platform,
@Optional() private _dir?: Directionality,
@Optional() @Inject(ANIMATION_MODULE_TYPE) public _animationMode?: string) {
super(_elementRef);
Expand All @@ -79,7 +77,7 @@ export class MatProgressBar extends _MatProgressBarMixinBase implements AfterVie
/** Adapter used by MDC to interact with the DOM. */
private _adapter: MDCLinearProgressAdapter = {
addClass: (className: string) => this._rootElement.classList.add(className),
forceLayout: () => this._platform.isBrowser && this._rootElement.offsetWidth,
forceLayout: () => this._rootElement.offsetWidth,
removeAttribute: (name: string) => this._rootElement.removeAttribute(name),
setAttribute: (name: string, value: string) => this._rootElement.setAttribute(name, value),
hasClass: (className: string) => this._rootElement.classList.contains(className),
Expand Down Expand Up @@ -184,8 +182,7 @@ export class MatProgressBar extends _MatProgressBarMixinBase implements AfterVie
private _syncFoundation() {
const foundation = this._foundation;

// Don't sync any state if we're not in a browser, because MDC uses some window APIs.
if (foundation && this._platform.isBrowser) {
if (foundation) {
const direction = this._dir ? this._dir.value : 'ltr';
const mode = this.mode;

Expand Down
Loading