Squeeze support module. Close gh-1165.

This commit is contained in:
Oleg 2013-02-11 00:01:27 +04:00 committed by Dave Methvin
parent eee2eaf1d7
commit 22a4e5bd0a

View File

@ -1,24 +1,19 @@
jQuery.support = (function( support ) { jQuery.support = (function( support ) {
var input = document.createElement("input"),
fragment = document.createDocumentFragment(),
div = document.createElement("div"),
select = document.createElement("select"),
opt = select.appendChild( document.createElement("option") );
var a, select, opt, input, fragment, // Finish early in limited environments
div = document.createElement("div"); if ( !input.type ) {
// Finish early in limited (non-browser) environments
div.innerHTML = "<a>a</a><input type='checkbox'/>";
a = div.getElementsByTagName("a")[ 0 ];
if ( !a ) {
return support; return support;
} }
// First batch of tests input.type = "checkbox";
select = document.createElement("select");
opt = select.appendChild( document.createElement("option") );
input = div.getElementsByTagName("input")[ 0 ];
a.style.cssText = "float:left;opacity:.5"; // Check the default checkbox/radio value ("" on old WebKit; "on" elsewhere)
support.checkOn = input.value === "";
// Check the default checkbox/radio value ("" on WebKit; "on" elsewhere)
support.checkOn = !!input.value;
// Must access the parent to make an option select properly // Must access the parent to make an option select properly
// Support: IE9, IE10 // Support: IE9, IE10
@ -33,6 +28,7 @@ jQuery.support = (function( support ) {
support.pixelPosition = false; support.pixelPosition = false;
// Make sure checked status is properly cloned // Make sure checked status is properly cloned
// Support: IE9, IE10
input.checked = true; input.checked = true;
support.noCloneChecked = input.cloneNode( true ).checked; support.noCloneChecked = input.cloneNode( true ).checked;
@ -42,25 +38,24 @@ jQuery.support = (function( support ) {
support.optDisabled = !opt.disabled; support.optDisabled = !opt.disabled;
// Check if an input maintains its value after becoming a radio // Check if an input maintains its value after becoming a radio
// Support: IE9, IE10, Opera
input = document.createElement("input"); input = document.createElement("input");
input.value = "t"; input.value = "t";
input.setAttribute( "type", "radio" ); input.type = "radio";
support.radioValue = input.value === "t"; support.radioValue = input.value === "t";
// #11217 - WebKit loses check when the name is after the checked attribute // #11217 - WebKit loses check when the name is after the checked attribute
input.setAttribute( "checked", "t" ); input.setAttribute( "checked", "t" );
input.setAttribute( "name", "t" ); input.setAttribute( "name", "t" );
fragment = document.createDocumentFragment();
fragment.appendChild( input ); fragment.appendChild( input );
// WebKit doesn't clone checked state correctly in fragments // old WebKit doesn't clone checked state correctly in fragments
support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked; support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
// Support: Firefox 17+ // Support: Firefox 17+
// Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP) // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
div.setAttribute( "onfocusin", "t" ); support.focusinBubbles = "onfocusin" in window;
support.focusinBubbles = "onfocusin" in window || div.attributes.onfocusin.expando === false;
div.style.backgroundClip = "content-box"; div.style.backgroundClip = "content-box";
div.cloneNode( true ).style.backgroundClip = ""; div.cloneNode( true ).style.backgroundClip = "";
@ -68,9 +63,9 @@ jQuery.support = (function( support ) {
// Run tests that need a body at doc ready // Run tests that need a body at doc ready
jQuery(function() { jQuery(function() {
var container, marginDiv, tds, var container, marginDiv,
divReset = "padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;", divReset = "padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",
body = document.getElementsByTagName("body")[0]; body = document.getElementsByTagName("body")[ 0 ];
if ( !body ) { if ( !body ) {
// Return for frameset docs that don't have a body // Return for frameset docs that don't have a body
@ -84,8 +79,9 @@ jQuery.support = (function( support ) {
body.appendChild( container ).appendChild( div ); body.appendChild( container ).appendChild( div );
div.innerHTML = ""; div.innerHTML = "";
div.style.cssText = "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;"; div.style.cssText = "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;";
support.boxSizing = ( div.offsetWidth === 4 );
support.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== 1 ); support.boxSizing = div.offsetWidth === 4;
support.doesNotIncludeMarginInBodyOffset = body.offsetTop !== 1;
// Use window.getComputedStyle because jsdom on node.js will break without it. // Use window.getComputedStyle because jsdom on node.js will break without it.
if ( window.getComputedStyle ) { if ( window.getComputedStyle ) {
@ -106,14 +102,8 @@ jQuery.support = (function( support ) {
} }
body.removeChild( container ); body.removeChild( container );
// Null elements to avoid leaks in IE
container = div = tds = marginDiv = null;
}); });
// Null elements to avoid leaks in IE
select = fragment = opt = a = input = null;
return support; return support;
})({}); })( {} );