toast.js : Cannot read properties of null (reading 'classList')
Prerequisites
-
I have searched for duplicate or closed issues -
I have validated any HTML to avoid common problems -
I have read the contributing guidelines
Describe the issue
I'm having the following issue in production on one website
Cannot read properties of null (reading 'classList')
At the lines https://github.com/twbs/bootstrap/blob/bf6240dad9a466e9d3bc682abf416e9e5b4c66df/js/src/toast.js#L114-L116
My guess is that the element is already removed when that callback is called (i'm calling .dispose in the bs.hidden callback event I don't know if that's related or not. it should work without issues either way in my opinion).
Reduced test cases
My proposal is to simply add a null check before and return early if this._element is null
Demo https://codepen.io/lekoalabe/pen/oNdPNXJ
click create modal click create toast accept sweet alert modal try to click close icon on toast => it triggers the error
What operating system(s) are you seeing the problem on?
Windows
What browser(s) are you seeing the problem on?
Chrome
What version of Bootstrap are you using?
v5.2.2