diff options
| author | Johann-S <[email protected]> | 2019-02-13 20:25:08 +0100 |
|---|---|---|
| committer | XhmikosR <[email protected]> | 2019-02-20 22:05:45 +0200 |
| commit | 08227506f23072c538b9af6db564c366681bf8a0 (patch) | |
| tree | 834a7a962b8b9695368b4fdf0305927a2e59a412 /js/src | |
| parent | 764bab29418309454ca81a9bf8e19d4f903c6e21 (diff) | |
| download | bootstrap-08227506f23072c538b9af6db564c366681bf8a0.tar.xz bootstrap-08227506f23072c538b9af6db564c366681bf8a0.zip | |
use only dataset to get data attributes
Diffstat (limited to 'js/src')
| -rw-r--r-- | js/src/dom/manipulator.js | 24 |
1 files changed, 3 insertions, 21 deletions
diff --git a/js/src/dom/manipulator.js b/js/src/dom/manipulator.js index b531a5586..5210f8b2c 100644 --- a/js/src/dom/manipulator.js +++ b/js/src/dom/manipulator.js @@ -37,30 +37,12 @@ const Manipulator = { }, getDataAttributes(element) { - if (typeof element === 'undefined' || element === null) { + if (!element) { return {} } - let attributes - if (Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'dataset')) { - attributes = { - ...element.dataset - } - } else { - attributes = {} - for (let i = 0; i < element.attributes.length; i++) { - const attribute = element.attributes[i] - - if (attribute.nodeName.indexOf('data-') !== -1) { - // remove 'data-' part of the attribute name - const attributeName = attribute - .nodeName - .substring('data-'.length) - .replace(/-./g, (str) => str.charAt(1).toUpperCase()) - - attributes[attributeName] = attribute.nodeValue - } - } + const attributes = { + ...element.dataset } Object.keys(attributes) |
