polyfillSvgUri
Polyfill for plain SVG as Data URI scheme.
The plain SVG without encoding (e.g. Base64, URL encoding, etc.) that is written in the Data URI scheme is easy to read, easy to edit and small size.
That Data URI scheme is written in for example, background-image
, list-style-image
, cursor
CSS properties, src
, data
attributes of <img>
, <input>
, <iframe>
, <object>
elements, etc..
But IE ignores it, and some browsers consider #
as the hash.
This polyfill solves those problems. It passes encoded SVG to IE, and it escapes #
.
Usage
Supported Places
The plain SVGs as Data URI scheme are enabled in:
CSS styles in stylesheets
For example: <link>
and <style>
tags
CSS styles in inline-style
For example:
src
and data
attributes of <img>
, <input>
, <iframe>
, <object>
tags, etc.
For example:
elment.style
CSS properties of For example:
documentstylebackgroundImage = 'url(\'data:image/svg+xml;utf8,<svg>...\')';
elment.style.cssText
property
For example:
documentstylecssText = 'background-image: url(\'data:image/svg+xml;utf8,<svg>...\');';
elment.style.setProperty
method
For example:
documentstyle;
New CSS rules
For example:
var styleSheet = documentstyleSheets0 selector = '#media-1' cssText = 'background-image: url(\'data:image/svg+xml;utf8,<svg>...\');';if styleSheetinsertRule styleSheet; else if styleSheetaddRule styleSheet;
Existing CSS rules
For example:
documentstyleSheets0cssRules0stylebackgroundImage = 'url(\'data:image/svg+xml;utf8,<svg>...\')';
elment.src
and elment.data
properties
For example:
documentsrc = 'data:image/svg+xml;utf8,<svg>...';