Skip to content

Commit

Permalink
update regions detect to include IE 10 iframe only version
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickkettner committed Feb 27, 2015
1 parent 8f488e9 commit e0fec68
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions feature-detects/css/regions.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ define(['Modernizr', 'createElement', 'docElement'], function( Modernizr, create
If the property name can't be found we'll get Boolean 'false' and fail quickly */
var flowFromProperty = Modernizr.prefixed('flowFrom');
var flowIntoProperty = Modernizr.prefixed('flowInto');
var result = false;

if (!flowFromProperty || !flowIntoProperty){
return false;
return result;
}

/* If CSS parsing is there, try to determine if regions actually work. */
var iframeContainer = createElement('iframe');
var container = createElement('div');
var content = createElement('div');
var region = createElement('div');
Expand Down Expand Up @@ -60,8 +62,27 @@ define(['Modernizr', 'createElement', 'docElement'], function( Modernizr, create

delta = parseInt(flowedRect.left - plainRect.left, 10);
docElement.removeChild(container);
content = region = container = undefined;

return (delta == 42);
if (delta == 42) {
result = true;
} else {
/* IE only allows for the content to come from iframes. This has the
* sideeffect of automatic collapsing of iframes once they get the flow-into
* property set. checking for a chachange on the height allows us to detect this
* in a sync way, without having to wait for a frame to load */

docElement.appendChild(iframeContainer);
plainRect = iframeContainer.getBoundingClientRect();
iframeContainer.style[flowIntoProperty] = flowName;
flowedRect = iframeContainer.getBoundingClientRect();

if (plainRect.height > 0 && plainRect.height !== flowedRect.height && flowedRect.height === 0) {
result = true;
}
}

content = region = container = iframeContainer = undefined;

return result;
});
});

0 comments on commit e0fec68

Please sign in to comment.