File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed
Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -229,20 +229,16 @@ class QrcodeDecoder {
229229 * refer to jsqr options: https://github.com/cozmo/jsQR
230230 */
231231 async decodeFromImage (
232- img : HTMLImageElement ,
232+ img : HTMLImageElement | string ,
233233 options : { crossOrigin ?: string } = { } ,
234234 ) {
235235 let imgDom : HTMLImageElement | null = null ;
236236 const opts = {
237237 ...this . defaultOption ,
238238 ...options ,
239239 } ;
240- if ( + img . nodeType > 0 ) {
241- if ( ! img . src ) {
242- throw new Error ( 'The ImageElement must contain a src' ) ;
243- }
244- imgDom = img ;
245- } else if ( typeof img === 'string' ) {
240+
241+ if ( typeof img === 'string' ) {
246242 imgDom = document . createElement ( 'img' ) ;
247243 if ( options . crossOrigin ) {
248244 imgDom . crossOrigin = options . crossOrigin ;
@@ -253,6 +249,11 @@ class QrcodeDecoder {
253249 imgDom ! . onload = ( ) => resolve ( true ) ;
254250 } ) ;
255251 await proms ( ) ;
252+ } else if ( + img . nodeType > 0 ) {
253+ if ( ! img . src ) {
254+ throw new Error ( 'The ImageElement must contain a src' ) ;
255+ }
256+ imgDom = img ;
256257 }
257258
258259 let code = null ;
You can’t perform that action at this time.
0 commit comments