Skip to content

Commit e5d44a7

Browse files
committed
fixed safari responsive image bug
1 parent 31875d8 commit e5d44a7

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "css-element-queries",
3-
"version": "0.3.1",
3+
"version": "0.3.2",
44
"description": "CSS-Element-Queries Polyfill. proof-of-concept for high-speed element dimension/media queries in valid css.",
55
"main": "index.js",
66
"directories": {

src/ElementQueries.js

+13-10
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@
228228
for (var i in element.children) {
229229
if(!element.children.hasOwnProperty(i)) continue;
230230

231-
if (element.children[i].tagName.toLowerCase() === 'img') {
231+
if (element.children[i].tagName && element.children[i].tagName.toLowerCase() === 'img') {
232232
children.push(element.children[i]);
233233

234234
var minWidth = element.children[i].getAttribute('min-width') || element.children[i].getAttribute('data-min-width');
@@ -297,6 +297,9 @@
297297
children[imageToDisplay].style.display = 'block';
298298
lastActiveImage = imageToDisplay;
299299
}
300+
} else {
301+
//make sure for initial check call the .src is set correctly
302+
children[imageToDisplay].src = sources[imageToDisplay];
300303
}
301304
}
302305

@@ -466,14 +469,14 @@
466469
var domLoaded = function (callback) {
467470
/* Internet Explorer */
468471
/*@cc_on
469-
@if (@_win32 || @_win64)
470-
document.write('<script id="ieScriptLoad" defer src="//:"><\/script>');
471-
document.getElementById('ieScriptLoad').onreadystatechange = function() {
472-
if (this.readyState == 'complete') {
473-
callback();
474-
}
475-
};
476-
@end @*/
472+
@if (@_win32 || @_win64)
473+
document.write('<script id="ieScriptLoad" defer src="//:"><\/script>');
474+
document.getElementById('ieScriptLoad').onreadystatechange = function() {
475+
if (this.readyState == 'complete') {
476+
callback();
477+
}
478+
};
479+
@end @*/
477480
/* Mozilla, Chrome, Opera */
478481
if (document.addEventListener) {
479482
document.addEventListener('DOMContentLoaded', callback, false);
@@ -503,4 +506,4 @@
503506
window.ElementQueries = ElementQueries;
504507
ElementQueries.listen();
505508
}
506-
})();
509+
})();

0 commit comments

Comments
 (0)