@@ -36,10 +36,10 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
3636 var serviceHost = 'img.imageboss.me' ;
3737 var serviceUrl = "https://" . concat ( serviceHost ) ;
3838 var localOptions = {
39- propKey : 'data-imageboss' ,
40- imgPropKey : ' data-imageboss-src',
41- bgPropKey : ' data-imageboss-bg-src',
42- sourcePropKey : ' data-imageboss-srcset',
39+ protectedKey : 'data-imageboss' ,
40+ imgPropKey : isDefined ( 'imgPropKey' , ' data-imageboss-src') ,
41+ bgPropKey : isDefined ( 'bgPropKey' , ' data-imageboss-bg-src') ,
42+ sourcePropKey : isDefined ( 'sourcePropKey' , ' data-imageboss-srcset') ,
4343 srcPropKey : isDefined ( 'srcPropKey' , 'src' ) ,
4444 lowsrcPropKey : isDefined ( 'lowsrcPropKey' , 'data-lowsrc' ) ,
4545 srcsetPropKey : isDefined ( 'srcsetPropKey' , 'srcset' ) ,
@@ -59,7 +59,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
5959 }
6060
6161 function isEnabled ( el , option ) {
62- var attributeValue = getAttribute ( el , option ) ;
62+ var attributeValue = getProtectedAttribute ( el , option ) ;
6363 var isAttrDefined = [ null , undefined ] . indexOf ( attributeValue ) == - 1 ;
6464 return isAttrDefined ? attributeValue === "true" && attributeValue !== true : isDefined ( option , false , localOptions ) ;
6565 }
@@ -89,11 +89,11 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
8989 }
9090
9191 function isImg ( element ) {
92- return ! ! getAttribute ( element , 'src' ) ;
92+ return ! ! element . getAttribute ( localOptions . imgPropKey ) ;
9393 }
9494
9595 function isBg ( element ) {
96- return ! ! getAttribute ( element , 'bg-src' ) ;
96+ return ! ! element . getAttribute ( localOptions . bgPropKey ) ;
9797 }
9898
9999 function buildSrc ( src ) {
@@ -111,23 +111,23 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
111111 }
112112
113113 function isFullyLoaded ( img ) {
114- return img && getAttribute ( img , 'loaded' ) ;
114+ return img && getProtectedAttribute ( img , 'loaded' ) ;
115115 }
116116
117- function getAttribute ( el , attr ) {
118- return el . getAttribute ( "" . concat ( localOptions . propKey , "-" ) . concat ( attr ) ) ;
117+ function getProtectedAttribute ( el , attr ) {
118+ return el . getAttribute ( "" . concat ( localOptions . protectedKey , "-" ) . concat ( attr ) ) ;
119119 }
120120
121- function setAttribute ( el , attr , val ) {
122- return el . setAttribute ( "" . concat ( localOptions . propKey , "-" ) . concat ( attr ) , val ) ;
121+ function setProtectedAttribute ( el , attr , val ) {
122+ return el . setAttribute ( "" . concat ( localOptions . protectedKey , "-" ) . concat ( attr ) , val ) ;
123123 }
124124
125125 function yieldValidSize ( size ) {
126126 return size && ! size . match ( / % / ) ? size : undefined ;
127127 }
128128
129129 function resolveSize ( img , type ) {
130- var size = getAttribute ( img , type ) || yieldValidSize ( img . getAttribute ( type ) ) ;
130+ var size = getProtectedAttribute ( img , type ) || yieldValidSize ( img . getAttribute ( type ) ) ;
131131 var attr = "client" . concat ( type . charAt ( 0 ) . toUpperCase ( ) + type . slice ( 1 ) ) ;
132132
133133 if ( size ) {
@@ -141,18 +141,18 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
141141
142142 function parseImageOptions ( img ) {
143143 return {
144- src : buildSrc ( getAttribute ( img , 'src' ) || getAttribute ( img , 'bg-src' ) ) ,
145- srcset : getAttribute ( img , 'srcset' ) ,
144+ src : buildSrc ( img . getAttribute ( localOptions . imgPropKey ) || img . getAttribute ( localOptions . bgPropKey ) ) ,
145+ srcset : img . getAttribute ( localOptions . srcsetPropKey ) ,
146146 sizes : img . getAttribute ( 'sizes' ) ,
147- operation : getAttribute ( img , 'operation' ) || 'width' ,
148- coverMode : getAttribute ( img , 'cover-mode' ) ,
147+ operation : getProtectedAttribute ( img , 'operation' ) || 'width' ,
148+ coverMode : getProtectedAttribute ( img , 'cover-mode' ) ,
149149 width : resolveSize ( img , 'width' ) ,
150150 height : resolveSize ( img , 'height' ) ,
151- source : getAttribute ( img , 'source' ) || localOptions . source ,
152- options : parseOptions ( getAttribute ( img , 'options' ) ) ,
151+ source : getProtectedAttribute ( img , 'source' ) || localOptions . source ,
152+ options : parseOptions ( getProtectedAttribute ( img , 'options' ) ) ,
153153 lowRes : isEnabled ( img , 'low-res' ) ,
154154 dprDisabled : isEnabled ( img , 'dpr' ) ,
155- class : ( getAttribute ( img , 'class' ) || '' ) . split ( ' ' ) . filter ( a => a )
155+ class : ( getProtectedAttribute ( img , 'class' ) || '' ) . split ( ' ' ) . filter ( a => a )
156156 } ;
157157 }
158158
@@ -303,7 +303,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
303303 return false ;
304304 }
305305
306- var src = buildSrc ( getAttribute ( img , 'src' ) || getAttribute ( img , 'srcset' ) || getAttribute ( img , 'bg-src' ) ) ;
306+ var src = buildSrc ( img . getAttribute ( localOptions . imgPropKey ) || img . getAttribute ( localOptions . imgsrcPropKey ) || img . getAttribute ( localOptions . bgPropKey ) ) ;
307307 var matchPattern = RegExp ( localOptions . matchHosts . join ( '|' ) ) ;
308308
309309 if ( localOptions . matchHosts . length && src && ! src . href . match ( matchPattern ) ) {
@@ -325,7 +325,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
325325 }
326326
327327 if ( ! source || localOptions . devMode ) {
328- setAttribute ( img , 'loaded' , true ) ;
328+ setProtectedAttribute ( img , 'loaded' , true ) ;
329329 return setImage ( img , src ) ;
330330 }
331331
0 commit comments