0
0
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:
GeoSot 2021-03-17 07:44:15 +02:00 committed by GitHub
parent c198eb6319
commit c5083d5fc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 3 deletions

View File

@ -54,7 +54,7 @@
},
{
"path": "./dist/js/bootstrap.min.js",
"maxSize": "16.25 kB"
"maxSize": "16.5 kB"
}
],
"ci": {

View File

@ -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 => {

View File

@ -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 ', () => {