Skip to content

Commit 5d49f37

Browse files
crisbetommalerba
authored andcommitted
fix(material-experimental/mdc-progress-bar): account for breaking changes in latest canary
Updates the repo to the latest MDC canary version and accounts for the breaking changes introduced in material-components/material-components-web@98b8434.
1 parent e441a8c commit 5d49f37

File tree

5 files changed

+536
-528
lines changed

5 files changed

+536
-528
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"@types/youtube": "^0.0.38",
5656
"@webcomponents/custom-elements": "^1.1.0",
5757
"core-js": "^2.6.9",
58-
"material-components-web": "^6.0.0-canary.265ecbad5.0",
58+
"material-components-web": "6.0.0-canary.17b9699c4.0",
5959
"rxjs": "^6.5.3",
6060
"systemjs": "0.19.43",
6161
"tslib": "^1.10.0",

src/material-experimental/mdc-progress-bar/progress-bar.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<div class="mdc-linear-progress">
2-
<div class="mdc-linear-progress__buffering-dots"></div>
3-
<div class="mdc-linear-progress__buffer"></div>
2+
<div class="mdc-linear-progress__buffer">
3+
<div class="mdc-linear-progress__buffer-bar"></div>
4+
<div class="mdc-linear-progress__buffer-dots"></div>
5+
</div>
46
<div class="mdc-linear-progress__bar mdc-linear-progress__primary-bar">
57
<span class="mdc-linear-progress__bar-inner"></span>
68
</div>

src/material-experimental/mdc-progress-bar/progress-bar.spec.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,28 +69,32 @@ describe('MDC-based MatProgressBar', () => {
6969
const primaryStyles =
7070
progressElement.nativeElement.querySelector('.mdc-linear-progress__primary-bar').style;
7171
const bufferStyles =
72-
progressElement.nativeElement.querySelector('.mdc-linear-progress__buffer').style;
72+
progressElement.nativeElement.querySelector('.mdc-linear-progress__buffer-bar').style;
73+
74+
// Parse out and round the value since different
75+
// browsers return the value with a different precision.
76+
const getBufferValue = () => Math.floor(parseInt(bufferStyles.flexBasis));
7377

7478
expect(primaryStyles.transform).toBe('scaleX(0)');
75-
expect(bufferStyles.transform).toBe('scaleX(1)');
79+
expect(getBufferValue()).toBe(100);
7680

7781
progressComponent.value = 40;
7882
expect(primaryStyles.transform).toBe('scaleX(0.4)');
79-
expect(bufferStyles.transform).toBe('scaleX(1)');
83+
expect(getBufferValue()).toBe(100);
8084

8185
progressComponent.value = 35;
8286
progressComponent.bufferValue = 55;
8387
expect(primaryStyles.transform).toBe('scaleX(0.35)');
84-
expect(bufferStyles.transform).toBe('scaleX(1)');
88+
expect(getBufferValue()).toBe(100);
8589

8690
progressComponent.mode = 'buffer';
8791
expect(primaryStyles.transform).toBe('scaleX(0.35)');
88-
expect(bufferStyles.transform).toEqual('scaleX(0.55)');
92+
expect(getBufferValue()).toEqual(55);
8993

9094
progressComponent.value = 60;
9195
progressComponent.bufferValue = 60;
9296
expect(primaryStyles.transform).toBe('scaleX(0.6)');
93-
expect(bufferStyles.transform).toEqual('scaleX(0.6)');
97+
expect(getBufferValue()).toEqual(60);
9498
});
9599

96100
it('should remove the `aria-valuenow` attribute in indeterminate mode', () => {

src/material-experimental/mdc-progress-bar/progress-bar.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,16 @@ export class MatProgressBar extends _MatProgressBarMixinBase implements AfterVie
7979
/** Adapter used by MDC to interact with the DOM. */
8080
private _adapter: MDCLinearProgressAdapter = {
8181
addClass: (className: string) => this._rootElement.classList.add(className),
82-
getBuffer: () => this._bufferBar,
83-
getPrimaryBar: () => this._primaryBar,
8482
forceLayout: () => this._platform.isBrowser && this._rootElement.offsetWidth,
8583
removeAttribute: (name: string) => this._rootElement.removeAttribute(name),
8684
setAttribute: (name: string, value: string) => this._rootElement.setAttribute(name, value),
8785
hasClass: (className: string) => this._rootElement.classList.contains(className),
8886
removeClass: (className: string) => this._rootElement.classList.remove(className),
89-
setStyle: (el: HTMLElement, styleProperty: string, value: string) => {
90-
(el.style as any)[styleProperty] = value;
87+
setPrimaryBarStyle: (styleProperty: string, value: string) => {
88+
(this._primaryBar.style as any)[styleProperty] = value;
89+
},
90+
setBufferBarStyle: (styleProperty: string, value: string) => {
91+
(this._bufferBar.style as any)[styleProperty] = value;
9192
}
9293
};
9394

@@ -151,7 +152,7 @@ export class MatProgressBar extends _MatProgressBarMixinBase implements AfterVie
151152

152153
this._rootElement = element.querySelector('.mdc-linear-progress') as HTMLElement;
153154
this._primaryBar = element.querySelector('.mdc-linear-progress__primary-bar') as HTMLElement;
154-
this._bufferBar = element.querySelector('.mdc-linear-progress__buffer') as HTMLElement;
155+
this._bufferBar = element.querySelector('.mdc-linear-progress__buffer-bar') as HTMLElement;
155156

156157
this._foundation = new MDCLinearProgressFoundation(this._adapter);
157158
this._foundation.init();

0 commit comments

Comments
 (0)