File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -129,6 +129,9 @@ if (import.meta.server && import.meta.prerender) {
129129
130130const initialLoad = useNuxtApp ().isHydrating
131131const imgEl = useTemplateRef (' imgEl' )
132+
133+ defineExpose ({ imgEl })
134+
132135onMounted (() => {
133136 if (placeholder .value || props .custom ) {
134137 const img = new Image ()
Original file line number Diff line number Diff line change @@ -154,6 +154,17 @@ describe('Renders simple image', () => {
154154 const domNonce = img . element . getAttribute ( 'nonce' )
155155 expect ( domNonce ) . toBe ( 'stub-nonce' )
156156 } )
157+
158+ it ( 'can access imgEl underlying img HTMLImageElement' , ( ) => {
159+ const img = mountImage ( {
160+ src : '/image.png' ,
161+ width : 300 ,
162+ height : 400 ,
163+ nonce : 'stub-nonce' ,
164+ } )
165+ expect ( img . getCurrentComponent ( ) . exposed ?. imgEl ) . toBeDefined ( )
166+ expect ( img . getCurrentComponent ( ) . exposed ?. imgEl . value ) . toBeInstanceOf ( HTMLImageElement )
167+ } )
157168} )
158169
159170const getImageLoad = ( cb = ( ) => { } ) => {
You can’t perform that action at this time.
0 commit comments