mirror of
https://github.com/feathericons/feather.git
synced 2023-08-10 21:13:24 +03:00
fix: Escaped & when generating SVG.
This commit is contained in:
parent
8263ca93c4
commit
66d2f39d80
12
src/icon.js
12
src/icon.js
@ -48,8 +48,18 @@ class Icon {
|
|||||||
*/
|
*/
|
||||||
function attrsToString(attrs) {
|
function attrsToString(attrs) {
|
||||||
return Object.keys(attrs)
|
return Object.keys(attrs)
|
||||||
.map(key => `${key}="${attrs[key]}"`)
|
.map(key => `${key}="${htmlEscape(attrs[key])}"`)
|
||||||
.join(' ');
|
.join(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Escapes unicode values in a string for XML compatibility (& => &)
|
||||||
|
* @param {string} str
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
function htmlEscape(str) {
|
||||||
|
if (typeof str !== 'string') return str;
|
||||||
|
return str.replace(/&/g, '&');
|
||||||
|
}
|
||||||
|
|
||||||
export default Icon;
|
export default Icon;
|
||||||
|
Loading…
Reference in New Issue
Block a user