Skip to content

Commit

Permalink
fixed safari responsive image bug
Browse files Browse the repository at this point in the history
  • Loading branch information
marcj committed Jan 31, 2016
1 parent 31875d8 commit e5d44a7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "css-element-queries",
"version": "0.3.1",
"version": "0.3.2",
"description": "CSS-Element-Queries Polyfill. proof-of-concept for high-speed element dimension/media queries in valid css.",
"main": "index.js",
"directories": {
Expand Down
23 changes: 13 additions & 10 deletions src/ElementQueries.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@
for (var i in element.children) {
if(!element.children.hasOwnProperty(i)) continue;

if (element.children[i].tagName.toLowerCase() === 'img') {
if (element.children[i].tagName && element.children[i].tagName.toLowerCase() === 'img') {
children.push(element.children[i]);

var minWidth = element.children[i].getAttribute('min-width') || element.children[i].getAttribute('data-min-width');
Expand Down Expand Up @@ -297,6 +297,9 @@
children[imageToDisplay].style.display = 'block';
lastActiveImage = imageToDisplay;
}
} else {
//make sure for initial check call the .src is set correctly
children[imageToDisplay].src = sources[imageToDisplay];
}
}

Expand Down Expand Up @@ -466,14 +469,14 @@
var domLoaded = function (callback) {
/* Internet Explorer */
/*@cc_on
@if (@_win32 || @_win64)
document.write('<script id="ieScriptLoad" defer src="//:"><\/script>');
document.getElementById('ieScriptLoad').onreadystatechange = function() {
if (this.readyState == 'complete') {
callback();
}
};
@end @*/
@if (@_win32 || @_win64)
document.write('<script id="ieScriptLoad" defer src="//:"><\/script>');
document.getElementById('ieScriptLoad').onreadystatechange = function() {
if (this.readyState == 'complete') {
callback();
}
};
@end @*/
/* Mozilla, Chrome, Opera */
if (document.addEventListener) {
document.addEventListener('DOMContentLoaded', callback, false);
Expand Down Expand Up @@ -503,4 +506,4 @@
window.ElementQueries = ElementQueries;
ElementQueries.listen();
}
})();
})();

0 comments on commit e5d44a7

Please sign in to comment.