diff options
author | Sam Potts <sam@potts.es> | 2019-04-25 12:11:06 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-25 12:11:06 +1000 |
commit | e644eeb5b62e6e2eb915d5915cb65ba8af88c05e (patch) | |
tree | 60f96b088ce8490429199163a5e71768b8a9b52c /src/js/utils/elements.js | |
parent | 2bd08cdc28bf55b7f7a169b02eb288d7b197b8d6 (diff) | |
parent | 5ddd9e02def654bb677c988403dbefbc4a32787c (diff) | |
download | plyr-e644eeb5b62e6e2eb915d5915cb65ba8af88c05e.tar.lz plyr-e644eeb5b62e6e2eb915d5915cb65ba8af88c05e.tar.xz plyr-e644eeb5b62e6e2eb915d5915cb65ba8af88c05e.zip |
Merge pull request #1423 from sampotts/develop
v3.5.4
Diffstat (limited to 'src/js/utils/elements.js')
-rw-r--r-- | src/js/utils/elements.js | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/js/utils/elements.js b/src/js/utils/elements.js index 6be634e5..9c1ddebc 100644 --- a/src/js/utils/elements.js +++ b/src/js/utils/elements.js @@ -4,6 +4,7 @@ import { toggleListener } from './events'; import is from './is'; +import { extend } from './objects'; // Wrap an element export function wrap(elements, wrapper) { @@ -137,7 +138,7 @@ export function getAttributesFromSelector(sel, existingAttributes) { } const attributes = {}; - const existing = existingAttributes; + const existing = extend({}, existingAttributes); sel.split(',').forEach(s => { // Remove whitespace @@ -147,7 +148,7 @@ export function getAttributesFromSelector(sel, existingAttributes) { // Get the parts and value const parts = stripped.split('='); - const key = parts[0]; + const [key] = parts; const value = parts.length > 1 ? parts[1].replace(/["']/g, '') : ''; // Get the first character @@ -156,11 +157,11 @@ export function getAttributesFromSelector(sel, existingAttributes) { switch (start) { case '.': // Add to existing classname - if (is.object(existing) && is.string(existing.class)) { - existing.class += ` ${className}`; + if (is.string(existing.class)) { + attributes.class = `${existing.class} ${className}`; + } else { + attributes.class = className; } - - attributes.class = className; break; case '#': @@ -179,7 +180,7 @@ export function getAttributesFromSelector(sel, existingAttributes) { } }); - return attributes; + return extend(existing, attributes); } // Toggle hidden |