From e2c7491ccdbc09055d578d2631d92e892359bad4 Mon Sep 17 00:00:00 2001 From: Sam Potts Date: Tue, 7 Nov 2017 09:58:37 +1100 Subject: =?UTF-8?q?Using=20the=20=E2=80=9Chref=E2=80=9D=20attribute=20on?= =?UTF-8?q?=20SVG=20if=20supported,=20using=20hasAttribute?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/js/controls.js | 11 ++++++++++- src/js/defaults.js | 4 ++-- src/js/plyr.js | 11 ++++++----- 3 files changed, 18 insertions(+), 8 deletions(-) (limited to 'src') 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 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 to 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: -- cgit v1.2.3