diff options
| author | Alessandro Chitolina <[email protected]> | 2017-09-15 16:07:24 +0200 |
|---|---|---|
| committer | XhmikosR <[email protected]> | 2019-02-20 22:05:45 +0200 |
| commit | 33211eefdfb27eff7ba21886e16f2efdc0efa3e6 (patch) | |
| tree | f8f3f3342a6c2c2363448346debf52beb4954b21 /js/src/dom/manipulator.js | |
| parent | 9f9712b98c92678c709b2ad0adfa954e3c120911 (diff) | |
| download | bootstrap-33211eefdfb27eff7ba21886e16f2efdc0efa3e6.tar.xz bootstrap-33211eefdfb27eff7ba21886e16f2efdc0efa3e6.zip | |
Rewritten modal without jquery (#23955)
* Trigger jquery events if available in event handler
* Rewritten modal without jquery
Diffstat (limited to 'js/src/dom/manipulator.js')
| -rw-r--r-- | js/src/dom/manipulator.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/js/src/dom/manipulator.js b/js/src/dom/manipulator.js index c12480234..b8136dda1 100644 --- a/js/src/dom/manipulator.js +++ b/js/src/dom/manipulator.js @@ -1,3 +1,5 @@ +import Util from '../util' + /** * -------------------------------------------------------------------------- * Bootstrap (v4.0.0-beta): dom/manipulator.js @@ -18,6 +20,24 @@ const Manipulator = { return input.bsChecked || input.checked } throw new Error('INPUT parameter is not an HTMLInputElement') + }, + + setDataAttribute(element, key, value) { + const $ = Util.jQuery + if (typeof $ !== 'undefined') { + $(element).data(key, value) + } + + element.setAttribute(`data-${key.replace(/[A-Z]/g, (chr) => `-${chr.toLowerCase()}`)}`, value) + }, + + removeDataAttribute(element, key) { + const $ = Util.jQuery + if (typeof $ !== 'undefined') { + $(element).removeData(key) + } + + element.removeAttribute(`data-${key.replace(/[A-Z]/g, (chr) => `-${chr.toLowerCase()}`)}`) } } |
