File tree Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Original file line number Diff line number Diff line change 88 < circle cx ="2.5 " cy ="2.5 " r ="2.5 "/>
99 </ pattern >
1010 </ defs >
11- < rect [attr.fill] ="'url(#' + progressbarId + ')' " width ="100% " height ="100% "/>
11+ < rect [attr.fill] ="'url(' + _currentPath + ' #' + progressbarId + ')' " width ="100% " height ="100% "/>
1212</ svg >
1313< div class ="mat-progress-bar-buffer mat-progress-bar-element " [ngStyle] ="_bufferTransform() "> </ div >
1414< div class ="mat-progress-bar-primary mat-progress-bar-fill mat-progress-bar-element " [ngStyle] ="_primaryTransform() "> </ div >
Original file line number Diff line number Diff line change 11import { TestBed , async , ComponentFixture } from '@angular/core/testing' ;
22import { Component } from '@angular/core' ;
33import { By } from '@angular/platform-browser' ;
4+ import { Location } from '@angular/common' ;
45import { MatProgressBarModule } from './index' ;
56
67
78describe ( 'MatProgressBar' , ( ) => {
9+ let fakePath = '/fake-path' ;
810
911 beforeEach ( async ( ( ) => {
1012 TestBed . configureTestingModule ( {
@@ -13,6 +15,10 @@ describe('MatProgressBar', () => {
1315 BasicProgressBar ,
1416 BufferProgressBar ,
1517 ] ,
18+ providers : [ {
19+ provide : Location ,
20+ useValue : { path : ( ) => fakePath }
21+ } ]
1622 } ) ;
1723
1824 TestBed . compileComponents ( ) ;
@@ -88,6 +94,11 @@ describe('MatProgressBar', () => {
8894 expect ( progressComponent . _bufferTransform ( ) ) . toEqual ( { transform : 'scaleX(0.6)' } ) ;
8995 } ) ;
9096
97+ it ( 'should prefix SVG references with the current path' , ( ) => {
98+ const rect = fixture . debugElement . query ( By . css ( 'rect' ) ) . nativeElement ;
99+ expect ( rect . getAttribute ( 'fill' ) ) . toMatch ( / ^ u r l \( \/ f a k e - p a t h # .* \) $ / ) ;
100+ } ) ;
101+
91102 it ( 'should not be able to tab into the underlying SVG element' , ( ) => {
92103 const svg = fixture . debugElement . query ( By . css ( 'svg' ) ) . nativeElement ;
93104 expect ( svg . getAttribute ( 'focusable' ) ) . toBe ( 'false' ) ;
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import {
1414 Optional ,
1515 ViewEncapsulation
1616} from '@angular/core' ;
17+ import { Location } from '@angular/common' ;
1718import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations' ;
1819import { CanColor , mixinColor } from '@angular/material/core' ;
1920
@@ -54,11 +55,21 @@ let progressbarId = 0;
5455 encapsulation : ViewEncapsulation . None ,
5556} )
5657export class MatProgressBar extends _MatProgressBarMixinBase implements CanColor {
57-
58+ /**
59+ * Current page path. Used to prefix SVG references which
60+ * won't work on Safari unless they're prefixed with the path.
61+ */
62+ _currentPath : string ;
5863
5964 constructor ( public _elementRef : ElementRef ,
60- @Optional ( ) @Inject ( ANIMATION_MODULE_TYPE ) public _animationMode ?: string ) {
65+ @Optional ( ) @Inject ( ANIMATION_MODULE_TYPE ) public _animationMode ?: string ,
66+ /**
67+ * @deprecated `location` parameter to be made required.
68+ * @deletion -target 8.0.0
69+ */
70+ location ?: Location ) {
6171 super ( _elementRef ) ;
72+ this . _currentPath = location ? location . path ( ) : '' ;
6273 }
6374
6475 /** Value of the progress bar. Defaults to zero. Mirrored to aria-valuenow. */
You can’t perform that action at this time.
0 commit comments