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

Add Manipulator object to add shortcuts for dom manipulations

This commit is contained in:
Johann-S
2017-09-05 14:35:52 +02:00
committed by XhmikosR
parent 44f38e4128
commit 9f9712b98c
7 changed files with 34 additions and 6 deletions

24
js/src/dom/manipulator.js Normal file
View File

@@ -0,0 +1,24 @@
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.0.0-beta): dom/manipulator.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
const Manipulator = {
setChecked(input, val) {
if (input instanceof HTMLInputElement) {
input.checked = val
input.bsChecked = val
}
},
isChecked(input) {
if (input instanceof HTMLInputElement) {
return input.bsChecked || input.checked
}
throw new Error('INPUT parameter is not an HTMLInputElement')
}
}
export default Manipulator