Fix for multiple sprites being requested (fixes #259)

This commit is contained in:
Sam 2016-06-02 10:18:33 +01:00
parent 521431e093
commit 7eec6c6739
4 changed files with 17 additions and 6 deletions

View File

@ -1,5 +1,8 @@
# Changelog
# v1.6.20
- Fix for multiple sprites being requested (fixes #259)
# v1.6.19
- Fix for scroll direction issues on volume control (fixes #258)

4
dist/plyr.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"name": "plyr",
"version": "1.6.19",
"version": "1.6.20",
"description": "A simple, accessible and customizable HTML5, YouTube and Vimeo media player",
"homepage": "http://plyr.io",
"main": "src/js/plyr.js",

View File

@ -1181,7 +1181,7 @@
// Only load external sprite using AJAX
if (iconUrl.external) {
_log('Loading external SVG sprite');
loadSprite(iconUrl.url);
loadSprite(iconUrl.url, "sprite-plyr");
}
else {
_log('Sprite will be used inline');
@ -3214,9 +3214,14 @@
}
// Load a sprite
function loadSprite(url) {
function loadSprite(url, id) {
var x = new XMLHttpRequest();
// If the id is set and sprite exists, bail
if (typeof id === 'string' && document.querySelector('#' + id) !== null) {
return;
}
// Check for CORS support
if ('withCredentials' in x) {
x.open('GET', url, true);
@ -3229,6 +3234,9 @@
x.onload = function() {
var c = document.createElement('div');
c.setAttribute('hidden', '');
if (typeof id === 'string') {
c.setAttribute('id', id);
}
c.innerHTML = x.responseText;
document.body.insertBefore(c, document.body.childNodes[0]);
}
@ -3317,7 +3325,7 @@
// Bail if not enabled
if (!config.enabled) {
return;
return null;
}
// Create new instance