Skip to content
This repository was archived by the owner on Sep 6, 2022. It is now read-only.

Commit 97d9fee

Browse files
committed
Conflicts
2 parents c43003b + a9a8e5f commit 97d9fee

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

dist/picturefill.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ window.matchMedia || (window.matchMedia = function() {
113113
pf.getWidthFromLength = function( length ) {
114114
// If a length is specified and doesn’t contain a percentage, and it is greater than 0 or using `calc`, use it. Else, use the `100vw` default.
115115
length = length && length.indexOf( "%" ) > -1 === false && ( parseFloat( length ) > 0 || length.indexOf( "calc(" ) > -1 ) ? length : "100vw";
116+
116117
/**
117118
* If length is specified in `vw` units, use `%` instead since the div we’re measuring
118119
* is injected at the top of the document.
@@ -138,7 +139,7 @@ window.matchMedia || (window.matchMedia = function() {
138139

139140
if ( pf.lengthEl.offsetWidth <= 0 ) {
140141
// Something has gone wrong. `calc()` is in use and unsupported, most likely. Default to `100vw` (`100%`, for broader support.):
141-
pf.lengthEl.style.cssText = "width: 100%;";
142+
pf.lengthEl.style.width = doc.documentElement.offsetWidth + "px";
142143
}
143144

144145
var offsetWidth = pf.lengthEl.offsetWidth;
@@ -412,13 +413,13 @@ window.matchMedia || (window.matchMedia = function() {
412413
picImg.currentSrc = picImg.src;
413414

414415
var style = picImg.style || {},
415-
hasWebkitBackfaceVisibility = "webkitBackfaceVisibility" in style,
416+
WebkitBackfaceVisibility = "webkitBackfaceVisibility" in style,
416417
currentZoom = style.zoom;
417418

418-
if (hasWebkitBackfaceVisibility) { // See: https://github.com/scottjehl/picturefill/issues/332
419+
if (WebkitBackfaceVisibility) { // See: https://github.com/scottjehl/picturefill/issues/332
419420
style.zoom = ".999";
420421

421-
hasWebkitBackfaceVisibility = picImg.offsetWidth;
422+
WebkitBackfaceVisibility = picImg.offsetWidth;
422423

423424
style.zoom = currentZoom;
424425
}

dist/picturefill.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/picturefill.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
pf.getWidthFromLength = function( length ) {
6565
// If a length is specified and doesn’t contain a percentage, and it is greater than 0 or using `calc`, use it. Else, use the `100vw` default.
6666
length = length && length.indexOf( "%" ) > -1 === false && ( parseFloat( length ) > 0 || length.indexOf( "calc(" ) > -1 ) ? length : "100vw";
67+
6768
/**
6869
* If length is specified in `vw` units, use `%` instead since the div we’re measuring
6970
* is injected at the top of the document.
@@ -89,7 +90,7 @@
8990

9091
if ( pf.lengthEl.offsetWidth <= 0 ) {
9192
// Something has gone wrong. `calc()` is in use and unsupported, most likely. Default to `100vw` (`100%`, for broader support.):
92-
pf.lengthEl.style.cssText = "width: 100%;";
93+
pf.lengthEl.style.width = doc.documentElement.offsetWidth + "px";
9394
}
9495

9596
var offsetWidth = pf.lengthEl.offsetWidth;
@@ -363,13 +364,13 @@
363364
picImg.currentSrc = picImg.src;
364365

365366
var style = picImg.style || {},
366-
hasWebkitBackfaceVisibility = "webkitBackfaceVisibility" in style,
367+
WebkitBackfaceVisibility = "webkitBackfaceVisibility" in style,
367368
currentZoom = style.zoom;
368369

369-
if (hasWebkitBackfaceVisibility) { // See: https://github.com/scottjehl/picturefill/issues/332
370+
if (WebkitBackfaceVisibility) { // See: https://github.com/scottjehl/picturefill/issues/332
370371
style.zoom = ".999";
371372

372-
hasWebkitBackfaceVisibility = picImg.offsetWidth;
373+
WebkitBackfaceVisibility = picImg.offsetWidth;
373374

374375
style.zoom = currentZoom;
375376
}

tests/tests.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,14 @@
4040
test("getWidthFromLength", function() {
4141
var calcTest = (function() {
4242
var fullWidthEl = document.createElement( "div" );
43-
document.documentElement.insertBefore( fullWidthEl, document.documentElement.firstChild );
43+
(document.body || document.documentElement).appendChild( fullWidthEl );
4444

4545
var gotWidth = pf.getWidthFromLength("calc(766px - 1em)");
46+
var returnValue = ( gotWidth === 750 || gotWidth === document.documentElement.offsetWidth );
4647

47-
return ( gotWidth === 750 || gotWidth === fullWidthEl.offsetWidth );
48+
fullWidthEl.parentNode.removeChild( fullWidthEl );
49+
50+
return returnValue;
4851
}());
4952

5053
equal( pf.getWidthFromLength("750px"), 750, "returns int value of width string" );
@@ -540,9 +543,11 @@
540543

541544
el.setAttribute( "sizes", "100vw" );
542545
el.setAttribute( "class", "no-src" );
543-
el.insertBefore( document.documentElement.firstChild, null );
546+
(document.body || document.documentElement).appendChild( el );
544547

545548
try { picturefill({ reevaluate: false, elements: document.querySelector( ".no-src" ) }); } catch (e) { console.log( e ); ok( false ); }
549+
550+
el.parentNode.removeChild( el );
546551
});
547552

548553
test( "Mixed content should be blocked", function() {

0 commit comments

Comments
 (0)