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 8
8
< circle cx ="2.5 " cy ="2.5 " r ="2.5 "/>
9
9
</ pattern >
10
10
</ defs >
11
- < rect [attr.fill] ="'url(#' + progressbarId + ')' " width ="100% " height ="100% "/>
11
+ < rect [attr.fill] ="'url(' + _currentPath + ' #' + progressbarId + ')' " width ="100% " height ="100% "/>
12
12
</ svg >
13
13
< div class ="mat-progress-bar-buffer mat-progress-bar-element " [ngStyle] ="_bufferTransform() "> </ div >
14
14
< 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 1
1
import { TestBed , async , ComponentFixture } from '@angular/core/testing' ;
2
2
import { Component } from '@angular/core' ;
3
3
import { By } from '@angular/platform-browser' ;
4
+ import { Location } from '@angular/common' ;
4
5
import { MatProgressBarModule } from './index' ;
5
6
6
7
7
8
describe ( 'MatProgressBar' , ( ) => {
9
+ let fakePath = '/fake-path' ;
8
10
9
11
beforeEach ( async ( ( ) => {
10
12
TestBed . configureTestingModule ( {
@@ -13,6 +15,10 @@ describe('MatProgressBar', () => {
13
15
BasicProgressBar ,
14
16
BufferProgressBar ,
15
17
] ,
18
+ providers : [ {
19
+ provide : Location ,
20
+ useValue : { path : ( ) => fakePath }
21
+ } ]
16
22
} ) ;
17
23
18
24
TestBed . compileComponents ( ) ;
@@ -88,6 +94,11 @@ describe('MatProgressBar', () => {
88
94
expect ( progressComponent . _bufferTransform ( ) ) . toEqual ( { transform : 'scaleX(0.6)' } ) ;
89
95
} ) ;
90
96
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
+
91
102
it ( 'should not be able to tab into the underlying SVG element' , ( ) => {
92
103
const svg = fixture . debugElement . query ( By . css ( 'svg' ) ) . nativeElement ;
93
104
expect ( svg . getAttribute ( 'focusable' ) ) . toBe ( 'false' ) ;
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import {
14
14
Optional ,
15
15
ViewEncapsulation
16
16
} from '@angular/core' ;
17
+ import { Location } from '@angular/common' ;
17
18
import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations' ;
18
19
import { CanColor , mixinColor } from '@angular/material/core' ;
19
20
@@ -54,11 +55,21 @@ let progressbarId = 0;
54
55
encapsulation : ViewEncapsulation . None ,
55
56
} )
56
57
export 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 ;
58
63
59
64
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
+ @Optional ( ) location ?: Location ) {
61
71
super ( _elementRef ) ;
72
+ this . _currentPath = location ? location . path ( ) : '' ;
62
73
}
63
74
64
75
/** Value of the progress bar. Defaults to zero. Mirrored to aria-valuenow. */
You can’t perform that action at this time.
0 commit comments