1 document.addEventListener('error', (e) => {
2 console.log('Document error triggered!')
3 if (!e.target) {
4 return console.log('Received event without target!')
5 }
6 const errorTarget = e.target
7 const imageErrorSource = errorTarget instanceof HTMLImageElement
8
9 if (!imageErrorSource) return false
10
11 return true
12 }, true)
1window.addEventListener("error", e => {
2 /* query selector images */
3 // image element on error => replace source
4})