Using the “href” attribute on SVG if supported, using hasAttribute
This commit is contained in:
parent
84505da84b
commit
e2c7491ccd
2
dist/plyr.js
vendored
2
dist/plyr.js
vendored
File diff suppressed because one or more lines are too long
2
dist/plyr.js.map
vendored
2
dist/plyr.js.map
vendored
File diff suppressed because one or more lines are too long
11
src/js/controls.js
vendored
11
src/js/controls.js
vendored
@ -73,7 +73,16 @@ const controls = {
|
||||
|
||||
// Create the <use> to reference sprite
|
||||
const use = document.createElementNS(namespace, 'use');
|
||||
use.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', `${iconPath}-${type}`);
|
||||
const path = `${iconPath}-${type}`;
|
||||
|
||||
// If the new `href` attribute is supported, use that
|
||||
// https://github.com/sampotts/plyr/issues/460
|
||||
// https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/xlink:href
|
||||
if ('href' in use) {
|
||||
use.setAttribute('href', path);
|
||||
} else {
|
||||
use.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', path);
|
||||
}
|
||||
|
||||
// Add <use> to <svg>
|
||||
icon.appendChild(use);
|
||||
|
@ -57,8 +57,8 @@ const defaults = {
|
||||
// Set loops
|
||||
loop: {
|
||||
active: false,
|
||||
start: null,
|
||||
end: null,
|
||||
// start: null,
|
||||
// end: null,
|
||||
},
|
||||
|
||||
// Speed default and options to display
|
||||
|
@ -170,21 +170,22 @@ class Plyr {
|
||||
case 'audio':
|
||||
this.type = type;
|
||||
|
||||
if (this.media.getAttribute('crossorigin') !== null) {
|
||||
if (this.media.hasAttribute('crossorigin')) {
|
||||
this.config.crossorigin = true;
|
||||
}
|
||||
if (this.media.getAttribute('autoplay') !== null) {
|
||||
if (this.media.hasAttribute('autoplay')) {
|
||||
this.config.autoplay = true;
|
||||
}
|
||||
if (this.media.getAttribute('playsinline') !== null) {
|
||||
if (this.media.hasAttribute('playsinline')) {
|
||||
this.config.inline = true;
|
||||
}
|
||||
if (this.media.getAttribute('muted') !== null) {
|
||||
if (this.media.hasAttribute('muted')) {
|
||||
this.config.muted = true;
|
||||
}
|
||||
if (this.media.getAttribute('loop') !== null) {
|
||||
if (this.media.hasAttribute('loop')) {
|
||||
this.config.loop.active = true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
Loading…
x
Reference in New Issue
Block a user