Improve Sprite checking (fixes #827)
This commit is contained in:
19
dist/plyr.polyfilled.js
vendored
19
dist/plyr.polyfilled.js
vendored
@ -6191,7 +6191,16 @@ var utils = {
|
||||
var hasId = utils.is.string(id);
|
||||
var isCached = false;
|
||||
|
||||
function updateSprite(data) {
|
||||
var exists = function exists() {
|
||||
return document.querySelectorAll('#' + id).length;
|
||||
};
|
||||
|
||||
function injectSprite(data) {
|
||||
// Check again incase of race condition
|
||||
if (hasId && exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Inject content
|
||||
this.innerHTML = data;
|
||||
|
||||
@ -6199,8 +6208,8 @@ var utils = {
|
||||
document.body.insertBefore(this, document.body.childNodes[0]);
|
||||
}
|
||||
|
||||
// Only load once
|
||||
if (!hasId || !document.querySelectorAll('#' + id).length) {
|
||||
// Only load once if ID set
|
||||
if (!hasId || !exists()) {
|
||||
// Create container
|
||||
var container = document.createElement('div');
|
||||
utils.toggleHidden(container, true);
|
||||
@ -6216,7 +6225,7 @@ var utils = {
|
||||
|
||||
if (isCached) {
|
||||
var data = JSON.parse(cached);
|
||||
updateSprite.call(container, data.content);
|
||||
injectSprite.call(container, data.content);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -6233,7 +6242,7 @@ var utils = {
|
||||
}));
|
||||
}
|
||||
|
||||
updateSprite.call(container, result);
|
||||
injectSprite.call(container, result);
|
||||
}).catch(function () {});
|
||||
}
|
||||
},
|
||||
|
Reference in New Issue
Block a user