mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-08 06:36:33 +02:00
Use more safe check for 'isDisabled' helper (#33385)
This commit is contained in:
@@ -54,7 +54,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "./dist/js/bootstrap.min.js",
|
"path": "./dist/js/bootstrap.min.js",
|
||||||
"maxSize": "16.25 kB"
|
"maxSize": "16.5 kB"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"ci": {
|
"ci": {
|
||||||
|
@@ -166,7 +166,7 @@ const isDisabled = element => {
|
|||||||
return element.disabled
|
return element.disabled
|
||||||
}
|
}
|
||||||
|
|
||||||
return element.getAttribute('disabled') !== 'false'
|
return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false'
|
||||||
}
|
}
|
||||||
|
|
||||||
const findShadowRoot = element => {
|
const findShadowRoot = element => {
|
||||||
|
@@ -347,16 +347,19 @@ describe('Util', () => {
|
|||||||
expect(Util.isDisabled(div2)).toEqual(true)
|
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 = [
|
fixtureEl.innerHTML = [
|
||||||
'<div>',
|
'<div>',
|
||||||
' <div id="element" disabled="false"></div>',
|
' <div id="element" disabled="false"></div>',
|
||||||
|
' <div id="element1" ></div>',
|
||||||
'</div>'
|
'</div>'
|
||||||
].join('')
|
].join('')
|
||||||
|
|
||||||
const div = fixtureEl.querySelector('#element')
|
const div = fixtureEl.querySelector('#element')
|
||||||
|
const div1 = fixtureEl.querySelector('#element1')
|
||||||
|
|
||||||
expect(Util.isDisabled(div)).toEqual(false)
|
expect(Util.isDisabled(div)).toEqual(false)
|
||||||
|
expect(Util.isDisabled(div1)).toEqual(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should return false if the element is not disabled ', () => {
|
it('should return false if the element is not disabled ', () => {
|
||||||
|
Reference in New Issue
Block a user