Skip to content

Commit

Permalink
rename 'cache' option to 'useCache'
Browse files Browse the repository at this point in the history
  • Loading branch information
dasboe committed Sep 27, 2018
1 parent 32fd489 commit 7c55cd9
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 42 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ Additionaly after loading the SVG, the value of the `src` attribute of the `<img

| Property name | Type | Default | Description |
| ------------- | ---- | ------- | ----------- |
| cache | boolean | `true` | If set to `true` the SVG will be cached using the absolute URL. The cache only persists for the lifetime of the page. Without caching images with the same absolute URL will trigger a new XMLHttpRequest but browser caching will still apply. |
| useCache | boolean | `true` | If set to `true` the SVG will be cached using the absolute URL. The cache only persists for the lifetime of the page. Without caching images with the same absolute URL will trigger a new XMLHttpRequest but browser caching will still apply. |
| copyAttributes | boolean | `true` | If set to `true` [attributes will be copied](#how-are-attributes-handled) from the `img` to the injected `svg` element. You may implement your own method for copying attributes in the `beforeInject` options hook. |
| makeIdsUnique | boolean | `true` | If set to `true` the id of elements in the `<defs>` element that can be references by property values (for example 'clipPath') are made unique by appending the string "--inject-X", where X is a running number which increases with each injection. This is done to avoid duplicate ids in the DOM. |
| beforeLoad | function(img) | `undefined` | Hook before SVG is loaded. The `img` element is passed as a parameter. If the hook returns a string it is used as the URL instead of the `img` element's `src` attribute. |
Expand Down Expand Up @@ -285,7 +285,7 @@ This example shows how to use SVGInject with mutiple options.

<script>
SVGInject.setOptions({
cache: false, // no caching
useCache: false, // no caching
copyAttributes: false, // do not copy attributes from `<img>` to `<svg>`
makeIdsUnique: false, // do not make ids used within the SVG unique
afterLoad: function(svg) {
Expand Down
12 changes: 6 additions & 6 deletions dist/svg-inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
var DIV_ELEMENT = document[CREATE_ELEMENT]('div');
var IS_SVG_SUPPORTED = typeof SVGRect != "undefined";
var DEFAULT_OPTIONS = {
cache: TRUE,
useCache: TRUE,
copyAttributes: TRUE,
makeIdsUnique: TRUE
};
Expand Down Expand Up @@ -304,7 +304,7 @@
* elements.
*
* Options:
* cache: If set to `true` the SVG will be cached using the absolute URL. Default value is `true`.
* useCache: If set to `true` the SVG will be cached using the absolute URL. Default value is `true`.
* copyAttributes: If set to `true` the attributes will be copied from `img` to `svg`. Dfault value
* is `true.
* makeIdsUnique: If set to `true` the id of elements in the `<defs>` element that can be references by
Expand Down Expand Up @@ -352,10 +352,10 @@
// URL path. Else use the imgElem src attribute value.
var src = (options.beforeLoad && options.beforeLoad(imgElem)) || imgElem.src;
var absUrl = getAbsoluteUrl(src);
var cache = options.cache;
var useCache = options.useCache;

var setSvgLoadCacheValue = function(val) {
if (cache) {
if (useCache) {
var svgLoad = svgLoadCache[absUrl];
for (var i = 0; i < svgLoad[LENGTH]; ++i) {
svgLoad[i](val);
Expand All @@ -366,7 +366,7 @@

removeEventListeners(imgElem);

if (cache) {
if (useCache) {
var svgLoad = svgLoadCache[absUrl];

var handleLoadValue = function(loadValue) {
Expand Down Expand Up @@ -404,7 +404,7 @@
// Invoke afterLoad hook which may modify the SVG element.
afterLoad(svgElem);

if (cache) {
if (useCache) {
// Update svgString because the SVG element can be modified in the afterLoad hook, so
// the modified SVG element is also used for all later cached injections
svgString = getXMLSerializer().serializeToString(svgElem);
Expand Down
14 changes: 7 additions & 7 deletions dist/svg-inject.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions examples/svg-inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
var DIV_ELEMENT = document[CREATE_ELEMENT]('div');
var IS_SVG_SUPPORTED = typeof SVGRect != "undefined";
var DEFAULT_OPTIONS = {
cache: TRUE,
useCache: TRUE,
copyAttributes: TRUE,
makeIdsUnique: TRUE
};
Expand Down Expand Up @@ -304,7 +304,7 @@
* elements.
*
* Options:
* cache: If set to `true` the SVG will be cached using the absolute URL. Default value is `true`.
* useCache: If set to `true` the SVG will be cached using the absolute URL. Default value is `true`.
* copyAttributes: If set to `true` the attributes will be copied from `img` to `svg`. Dfault value
* is `true.
* makeIdsUnique: If set to `true` the id of elements in the `<defs>` element that can be references by
Expand Down Expand Up @@ -352,10 +352,10 @@
// URL path. Else use the imgElem src attribute value.
var src = (options.beforeLoad && options.beforeLoad(imgElem)) || imgElem.src;
var absUrl = getAbsoluteUrl(src);
var cache = options.cache;
var useCache = options.useCache;

var setSvgLoadCacheValue = function(val) {
if (cache) {
if (useCache) {
var svgLoad = svgLoadCache[absUrl];
for (var i = 0; i < svgLoad[LENGTH]; ++i) {
svgLoad[i](val);
Expand All @@ -366,7 +366,7 @@

removeEventListeners(imgElem);

if (cache) {
if (useCache) {
var svgLoad = svgLoadCache[absUrl];

var handleLoadValue = function(loadValue) {
Expand Down Expand Up @@ -404,7 +404,7 @@
// Invoke afterLoad hook which may modify the SVG element.
afterLoad(svgElem);

if (cache) {
if (useCache) {
// Update svgString because the SVG element can be modified in the afterLoad hook, so
// the modified SVG element is also used for all later cached injections
svgString = getXMLSerializer().serializeToString(svgElem);
Expand Down
14 changes: 7 additions & 7 deletions examples/svg-inject.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7c55cd9

Please sign in to comment.