1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-09-27 22:09:04 +02:00

Rewritten modal without jquery (#23955)

* Trigger jquery events if available in event handler

* Rewritten modal without jquery
This commit is contained in:
Alessandro Chitolina
2017-09-15 16:07:24 +02:00
committed by XhmikosR
parent 9f9712b98c
commit 33211eefdf
12 changed files with 596 additions and 236 deletions

View File

@@ -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()}`)}`)
}
}