mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-07 06:06:47 +02:00
Use more safe check for 'isDisabled' helper (#33385)
This commit is contained in:
@@ -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 ', () => {
|
||||
|
Reference in New Issue
Block a user