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 @@ -132,6 +132,9 @@ if (import.meta.server && import.meta.prerender) {
132
132
133
133
const initialLoad = useNuxtApp ().isHydrating
134
134
const imgEl = useTemplateRef (' imgEl' )
135
+
136
+ defineExpose ({ imgEl })
137
+
135
138
onMounted (() => {
136
139
if (placeholder .value || props .custom ) {
137
140
const img = new Image ()
Original file line number Diff line number Diff line change @@ -153,6 +153,17 @@ describe('Renders simple image', () => {
153
153
const domNonce = img . element . getAttribute ( 'nonce' )
154
154
expect ( domNonce ) . toBe ( 'stub-nonce' )
155
155
} )
156
+
157
+ it . only ( 'can access imgEl underlying img HTMLImageElement' , ( ) => {
158
+ const img = mountImage ( {
159
+ src : '/image.png' ,
160
+ width : 300 ,
161
+ height : 400 ,
162
+ nonce : 'stub-nonce' ,
163
+ } )
164
+ expect ( img . getCurrentComponent ( ) . exposed ?. imgEl ) . toBeDefined ( )
165
+ expect ( img . getCurrentComponent ( ) . exposed ?. imgEl . value ) . toBeInstanceOf ( HTMLImageElement )
166
+ } )
156
167
} )
157
168
158
169
const getImageLoad = ( cb = ( ) => { } ) => {
You can’t perform that action at this time.
0 commit comments