mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
fix(image): avoid onload to be overwritten (#1689)
This commit is contained in:
@@ -99,5 +99,18 @@ describe('Image.vue', () => {
|
||||
expect(result).toBeTruthy()
|
||||
})
|
||||
|
||||
test('emit load event', async () => {
|
||||
const handleLoad = jest.fn()
|
||||
const wrapper = mount(Image, {
|
||||
props: {
|
||||
src: IMAGE_SUCCESS,
|
||||
onLoad: handleLoad,
|
||||
},
|
||||
})
|
||||
await doubleWait()
|
||||
expect(wrapper.find('.el-image__inner').exists()).toBe(true)
|
||||
expect(handleLoad).toBeCalled()
|
||||
})
|
||||
|
||||
//@todo lazy image test
|
||||
})
|
||||
|
||||
@@ -185,6 +185,8 @@ export default defineComponent({
|
||||
// so it can behave consistently
|
||||
Object.keys(attributes)
|
||||
.forEach(key => {
|
||||
// avoid onload to be overwritten
|
||||
if (key.toLowerCase() === 'onload') return
|
||||
const value = attributes[key]
|
||||
img.setAttribute(key, value)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user