Skip to content

Commit

Permalink
Version bump.
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Farrell committed Sep 21, 2015
1 parent c5ff472 commit 8a08e52
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ If you're using NPM to manage your dependencies you can include this plugin as a

## Changelog

- **26/08/15:** 2.1.3 – Version bump.
- **26/08/15:** 2.1.2 – Removed localStorage. It just doesn't work that well when SVG's change etc.
- **31/07/15:** 2.1.1 – Added localStorage support to avoid making fresh HTTP request on every page load. When the contents of the SVG is loaded it is added to localStorage and then on repeat page loads the source is grabbed from localStorage.
- **31/07/15:** 2.0.1 - Major upgrade. Added AMD support and fixed a long standing issue that would result in a warning in Google Chrome as we weren't handling the GET requests asynchronously.
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "inline-svg",
"version": "2.1.2",
"version": "2.1.3",
"homepage": "https://github.com/jonnyhaynes/inline-svg",
"authors": [
"Jonny Haynes <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "inline-svg",
"version": "2.1.2",
"version": "2.1.3",
"devDependencies": {
"grunt": "0.4.5",
"grunt-cli": "0.1.13",
Expand Down
59 changes: 58 additions & 1 deletion src/inlineSVG.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// Variables
var inlineSVG = {},
supports = !!document.querySelector && !!root.addEventListener,
cache = {},
settings;

// Defaults
Expand Down Expand Up @@ -69,7 +70,7 @@

/**
* Grab all the SVGs that match the selector
* @public
* @private
*/
var getAll = function () {

Expand All @@ -78,6 +79,58 @@

};

/**
* Grab the source of the SVG
* @private
*/
var getSource = function (svgURL) {

// if the browser supports the fetch api
if (self.fetch) {

fetch(svgURL).then(function (response) {
if(response.ok) {
console.log(response);
} else {
console.log('There was an error with response.');
}
}).catch(function (error) {
console.error('There has been a problem getting the source of the SVG: ' + error.message);
});

}

// the browser doesn't support the fetch api
else {

var request = new XMLHttpRequest();
request.open('GET', src, true);

request.onload = function () {

}

request.onerror = function () {
console.error('There was an error connecting to the origin server.');
};

request.send();

}

};

/**
*
*/
var parseAsXML = function (response) {

var parser = new DOMParser(),
result = parser.parseFromString(response.responseText, 'text/xml'),
inlinedSVG = result.getElementsByTagName('svg')[0];

};

/**
* Inline all the SVGs in the array
* @public
Expand All @@ -92,6 +145,10 @@
var src = svg.src || svg.getAttribute('data-src'),
attributes = svg.attributes;

cache[src] = "";

getSource(src);

// Get the contents of the SVG
var request = new XMLHttpRequest();
request.open('GET', src, true);
Expand Down

0 comments on commit 8a08e52

Please sign in to comment.