Skip to content

Commit

Permalink
Some code cleanup
Browse files Browse the repository at this point in the history
* Makes use of guard pattern to avoid nesting
* Checks this.avoid first to avoid calling this.hasClass when
  set to false
  • Loading branch information
nicholasruunu committed Aug 5, 2015
1 parent 94813f8 commit e08b459
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions svgeezy.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,19 @@ window.svgeezy = function() {

fallbacks: function() {
while(--this.imgL) {
if(!this.hasClass(this.images[this.imgL], this.avoid) || !this.avoid) {
var src = this.images[this.imgL].getAttribute('src');
if(src === null) {
continue;
}
if(this.getFileExt(src) == 'svg') {
var newSrc = src.replace('.svg', '.' + this.filetype);
this.images[this.imgL].setAttribute('src', newSrc);
}
if(this.avoid && this.hasClass(this.images[this.imgL], this.avoid)) {
continue;
}
var src = this.images[this.imgL].getAttribute('src');
if(src === null) {
continue;
}
if(this.getFileExt(src) != 'svg') {
continue;
}
var newSrc = src.replace('.svg', '.' + this.filetype);
this.images[this.imgL].setAttribute('src', newSrc);

}
},

Expand Down

0 comments on commit e08b459

Please sign in to comment.