mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-08 22:56:46 +02:00
Add Manipulator object to add shortcuts for dom manipulations
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
import Data from './dom/data'
|
||||
import EventHandler from './dom/eventHandler'
|
||||
import Manipulator from './dom/manipulator'
|
||||
import SelectorEngine from './dom/selectorEngine'
|
||||
|
||||
/**
|
||||
@@ -93,7 +94,7 @@ class Button {
|
||||
rootElement.classList.contains('disabled')) {
|
||||
return
|
||||
}
|
||||
input.checked = !this._element.classList.contains(ClassName.ACTIVE)
|
||||
Manipulator.setChecked(input, !this._element.classList.contains(ClassName.ACTIVE))
|
||||
EventHandler.trigger(input, 'change')
|
||||
}
|
||||
|
||||
|
@@ -85,7 +85,7 @@ const nativeEvents = [
|
||||
'orientationchange',
|
||||
'touchstart', 'touchmove', 'touchend', 'touchcancel',
|
||||
'gesturestart', 'gesturechange', 'gestureend',
|
||||
'focus', 'blur', 'change', 'reset', 'select', 'submit',
|
||||
'focus', 'blur', 'change', 'reset', 'select', 'submit', 'focusin', 'focusout',
|
||||
'load', 'unload', 'beforeunload', 'resize', 'move', 'DOMContentLoaded', 'readystatechange',
|
||||
'error', 'abort', 'scroll'
|
||||
]
|
||||
|
24
js/src/dom/manipulator.js
Normal file
24
js/src/dom/manipulator.js
Normal 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
|
Reference in New Issue
Block a user