mirror of
https://github.com/twbs/bootstrap.git
synced 2025-02-19 16:54:24 +01:00
Use more safe check for 'isDisabled' helper (#33385)
This commit is contained in:
parent
c198eb6319
commit
c5083d5fc3
@ -54,7 +54,7 @@
|
||||
},
|
||||
{
|
||||
"path": "./dist/js/bootstrap.min.js",
|
||||
"maxSize": "16.25 kB"
|
||||
"maxSize": "16.5 kB"
|
||||
}
|
||||
],
|
||||
"ci": {
|
||||
|
@ -166,7 +166,7 @@ const isDisabled = element => {
|
||||
return element.disabled
|
||||
}
|
||||
|
||||
return element.getAttribute('disabled') !== 'false'
|
||||
return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false'
|
||||
}
|
||||
|
||||
const findShadowRoot = element => {
|
||||
|
@ -347,16 +347,19 @@ describe('Util', () => {
|
||||
expect(Util.isDisabled(div2)).toEqual(true)
|
||||
})
|
||||
|
||||
it('should return false if the element has disabled attribute with "false" value', () => {
|
||||
it('should return false if the element has disabled attribute with "false" value, or doesn\'t have attribute', () => {
|
||||
fixtureEl.innerHTML = [
|
||||
'<div>',
|
||||
' <div id="element" disabled="false"></div>',
|
||||
' <div id="element1" ></div>',
|
||||
'</div>'
|
||||
].join('')
|
||||
|
||||
const div = fixtureEl.querySelector('#element')
|
||||
const div1 = fixtureEl.querySelector('#element1')
|
||||
|
||||
expect(Util.isDisabled(div)).toEqual(false)
|
||||
expect(Util.isDisabled(div1)).toEqual(false)
|
||||
})
|
||||
|
||||
it('should return false if the element is not disabled ', () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user