1 file changed +11
-20
lines changed Original file line number Diff line number Diff line change @@ -2284,28 +2284,19 @@ var tarteaucitron = {
2284
2284
} ,
2285
2285
"fallback" : function ( matchClass , content , noInner ) {
2286
2286
"use strict" ;
2287
- var elems = document . getElementsByTagName ( '*' ) ,
2288
- i ,
2289
- index = 0 ;
2290
-
2291
- for ( i in elems ) {
2292
- if ( elems [ i ] !== undefined ) {
2293
- for ( index = 0 ; index < matchClass . length ; index += 1 ) {
2294
- if ( ( ' ' + elems [ i ] . className + ' ' )
2295
- . indexOf ( ' ' + matchClass [ index ] + ' ' ) > - 1 ) {
2296
- if ( typeof content === 'function' ) {
2297
- if ( noInner === true ) {
2298
- content ( elems [ i ] ) ;
2299
- } else {
2300
- elems [ i ] . innerHTML = content ( elems [ i ] ) ;
2301
- }
2302
- } else {
2303
- elems [ i ] . innerHTML = content ;
2304
- }
2305
- }
2287
+ const selector = matchClass . map ( cls => `.${ cls } ` ) . join ( ', ' ) ;
2288
+ const elems = document . querySelectorAll ( selector ) ;
2289
+ elems . forEach ( ( elem ) => {
2290
+ if ( typeof content === 'function' ) {
2291
+ if ( noInner === true ) {
2292
+ content ( elem ) ;
2293
+ } else {
2294
+ elem . innerHTML = content ( elem ) ;
2306
2295
}
2296
+ } else {
2297
+ elem . innerHTML = content ;
2307
2298
}
2308
- }
2299
+ } ) ;
2309
2300
} ,
2310
2301
"engage" : function ( id ) {
2311
2302
"use strict" ;
0 commit comments