Skip to content

Commit

Permalink
allow rias plugin to work with the bgset plugin (see #101)
Browse files Browse the repository at this point in the history
  • Loading branch information
aFarkas committed May 22, 2015
1 parent cbb807e commit e6166d1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions plugins/rias/ls.rias.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
}

addEventListener('lazybeforeunveil', function(e){
var elem, src, elemOpts, parent, sources, i, len, sourceSrc, sizes, detail, hasPlaceholder;
var elem, src, elemOpts, parent, sources, i, len, sourceSrc, sizes, detail, hasPlaceholder, modified, emptyList;
elem = e.target;

if(e.defaultPrevented || riasCfg.disabled || !((sizes = elem.getAttribute(config.sizesAttr) || elem.getAttribute('sizes')) && regAllowedSizes.test(sizes))){return;}
Expand All @@ -190,14 +190,23 @@
if(elemOpts.isPicture && (parent = elem.parentNode)){
sources = parent.getElementsByTagName('source');
for(i = 0, len = sources.length; i < len; i++){
if ( regWidth.test(sourceSrc = getSrc(sources[i])) ){
if ( hasPlaceholder || regWidth.test(sourceSrc = getSrc(sources[i])) ){
setSrc(sourceSrc, elemOpts, sources[i]);
modified = true;
}
}
}

if ( hasPlaceholder || regWidth.test(src) ){
setSrc(src, elemOpts, elem);
} else if (modified) {
emptyList = [];
emptyList.srcset = [];
emptyList.isPicture = true;
Object.defineProperty(elem, '_lazyrias', {
value: emptyList,
writable: true
});
}

if(sizes != 'auto'){
Expand Down Expand Up @@ -300,7 +309,7 @@
return;
}

if(!elem._lazyrias && (!e.detail.dataAttr || !getWSet(elem, true))){
if(!('_lazyrias' in elem) && (!e.detail.dataAttr || !getWSet(elem, true))){
return;
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/rias/ls.rias.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e6166d1

Please sign in to comment.