aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSam Potts <me@sampotts.me>2017-11-07 09:58:37 +1100
committerSam Potts <me@sampotts.me>2017-11-07 09:58:37 +1100
commite2c7491ccdbc09055d578d2631d92e892359bad4 (patch)
tree6328a1413649848bc9f9b0910fafb402067b096a /src
parent84505da84ba97ae1b189f9c695228d324e9dc3b8 (diff)
downloadplyr-e2c7491ccdbc09055d578d2631d92e892359bad4.tar.lz
plyr-e2c7491ccdbc09055d578d2631d92e892359bad4.tar.xz
plyr-e2c7491ccdbc09055d578d2631d92e892359bad4.zip
Using the “href” attribute on SVG if supported, using hasAttribute
Diffstat (limited to 'src')
-rw-r--r--src/js/controls.js11
-rw-r--r--src/js/defaults.js4
-rw-r--r--src/js/plyr.js11
3 files changed, 18 insertions, 8 deletions
diff --git a/src/js/controls.js b/src/js/controls.js
index ac7ba2b6..4f6ef365 100644
--- a/src/js/controls.js
+++ b/src/js/controls.js
@@ -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);
diff --git a/src/js/defaults.js b/src/js/defaults.js
index a3d95bb4..b11aaf9d 100644
--- a/src/js/defaults.js
+++ b/src/js/defaults.js
@@ -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
diff --git a/src/js/plyr.js b/src/js/plyr.js
index 355fe5cb..08e722c1 100644
--- a/src/js/plyr.js
+++ b/src/js/plyr.js
@@ -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: