Skip to content

Commit ab8f98f

Browse files
crisbetotinayuangao
authored andcommitted
fix(progress-bar): buffer animation not working in IE (#2941)
* fix(progress-bar): buffer animation not working in IE Fixes an issue that caused IE to throw an XML error and not render the buffering animation. The problem was that we url-escape the SVG itself, but not the hex color which gets added later on, which causes the url to be invalid. This seems to be handled by most browsers automatically, but not IE. Fixes #2881. * chore: fix linter error * Update from md-color to mat-color
1 parent 6381948 commit ab8f98f

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

src/lib/progress-bar/_progress-bar-theme.scss

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,31 @@
4848

4949
// TODO(josephperrott): Find better way to inline svgs.
5050
// In buffer mode a repeated SVG object is used as a background.
51-
// Each of the following defines the SVG object for each of the class defined colors.
51+
// Each of the following defines the SVG object for each of the class defined colors.
5252
//
53-
// The string is a URL encoded version of:
53+
// The string is a URL encoded version of:
5454
//
55-
// <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
56-
// version="1.1" x="0px" y="0px" enable-background="new 0 0 5 2"
57-
// xml:space="preserve" viewBox="0 0 5 2" preserveAspectRatio="none slice">
58-
// <circle cx="1" cy="1" r="1" fill="{INJECTED_COLOR}"/>
59-
// </svg>
55+
// <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
56+
// version="1.1" x="0px" y="0px" enable-background="new 0 0 5 2"
57+
// xml:space="preserve" viewBox="0 0 5 2" preserveAspectRatio="none slice">
58+
// <circle cx="1" cy="1" r="1" fill="{INJECTED_COLOR}"/>
59+
// </svg>
6060
@function _mat-progress-bar-buffer($palette, $hue) {
61-
$result: '' +
62-
'data:image/svg+xml;charset=UTF-8,%3Csvg%20version%3D%271.1%27%20xmlns%3D%27http%3A%2F%2F' +
63-
'www.w3.org%2F2000%2Fsvg%27%20xmlns%3Axlink%3D%27http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%2' +
64-
'7%20x%3D%270px%27%20y%3D%270px%27%20enable-background%3D%27new%200%200%205%202%27%20xml%' +
65-
'3Aspace%3D%27preserve%27%20viewBox%3D%270%200%205%202%27%20preserveAspectRatio%3D%27none' +
66-
'%20slice%27%3E%3Ccircle%20cx%3D%271%27%20cy%3D%271%27%20r%3D%271%27%20fill%3D%27' +
67-
mat-color($palette, $hue) + '%27%2F%3E%3C%2Fsvg%3E';
61+
$color: mat-color($palette, $hue) + '';
62+
63+
// We also need to escape the hash in hex colors,
64+
// otherwise IE will throw an XML error.
65+
@if str-index($color, '#') == 1 {
66+
$color: '%23' + str-slice($color, 2);
67+
}
68+
69+
$result: '' +
70+
'data:image/svg+xml;charset=UTF-8,%3Csvg%20version%3D%271.1%27%20xmlns%3D%27http%3A%2F%2F' +
71+
'www.w3.org%2F2000%2Fsvg%27%20xmlns%3Axlink%3D%27http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%2' +
72+
'7%20x%3D%270px%27%20y%3D%270px%27%20enable-background%3D%27new%200%200%205%202%27%20xml%' +
73+
'3Aspace%3D%27preserve%27%20viewBox%3D%270%200%205%202%27%20preserveAspectRatio%3D%27none' +
74+
'%20slice%27%3E%3Ccircle%20cx%3D%271%27%20cy%3D%271%27%20r%3D%271%27%20fill%3D%27' +
75+
$color + '%27%2F%3E%3C%2Fsvg%3E';
6876

6977
@return url($result);
7078
}

0 commit comments

Comments
 (0)