Skip to content

Commit

Permalink
add detect for data uri iframes
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickkettner committed Jul 12, 2016
1 parent 1909ce3 commit 9710037
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
40 changes: 40 additions & 0 deletions feature-detects/iframe/datauri.js
@@ -0,0 +1,40 @@
/*!
{
"name": "DataURI based iframe",
"property": "datauriiframe",
"notes": [{
"name": "Internet Explorer reference on the data Protocol",
"href": "https://msdn.microsoft.com/en-us/library/cc848897(v=vs.85).aspx"
}]
}
!*/
/* DOC
Detects support for using a data uri for iframes
*/
define(['Modernizr', 'createElement', 'docElement', 'getBody'], function(Modernizr, createElement, docElement, getBody) {
Modernizr.addTest('datauriiframe', function() {
var iframe = createElement('iframe');
var body = getBody();
var support;

iframe.style.display = 'none';
iframe.src = 'data:text/html;base64,Kg==';

try {
if (!docElement.contains(body)) {
docElement.appendChild(body);
}
body.appendChild(iframe);
support = !!iframe.contentDocument;
} catch (e) {
} finally {
body.removeChild(iframe);

if (body.fake && body.parentNode) {
body.parentNode.removeChild(body);
}
}

return support;
});
});
1 change: 1 addition & 0 deletions lib/config-all.json
Expand Up @@ -243,6 +243,7 @@
"templatestrings",
"test/css/scrollsnappoints",
"test/elem/bdi",
"test/iframe/datauri",
"test/img/crossorigin",
"test/ligatures",
"textarea/maxlength",
Expand Down

0 comments on commit 9710037

Please sign in to comment.