-
Notifications
You must be signed in to change notification settings - Fork 20.6k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
define([ | ||
"../core", | ||
"../ajax", | ||
"../support" | ||
], function( jQuery ) { | ||
"../var/support", | ||
"../ajax" | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
mgol
Author
Member
|
||
], function( jQuery, support ) { | ||
|
||
jQuery.ajaxSettings.xhr = function() { | ||
try { | ||
|
@@ -33,13 +33,13 @@ if ( window.ActiveXObject ) { | |
}); | ||
} | ||
|
||
jQuery.support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported ); | ||
jQuery.support.ajax = xhrSupported = !!xhrSupported; | ||
support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported ); | ||
support.ajax = xhrSupported = !!xhrSupported; | ||
|
||
jQuery.ajaxTransport(function( options ) { | ||
var callback; | ||
// Cross domain only allowed if supported through XMLHttpRequest | ||
if ( jQuery.support.cors || xhrSupported && !options.crossDomain ) { | ||
if ( support.cors || xhrSupported && !options.crossDomain ) { | ||
return { | ||
send: function( headers, complete ) { | ||
var i, id, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
define([ | ||
"../var/support" | ||
], function( support ) { | ||
|
||
(function () { | ||
var input = document.createElement( "input" ), | ||
select = document.createElement( "select" ), | ||
opt = select.appendChild( document.createElement( "option" ) ); | ||
|
||
input.type = "checkbox"; | ||
|
||
// Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3 | ||
// Check the default checkbox/radio value ("" on old WebKit; "on" elsewhere) | ||
support.checkOn = input.value !== ""; | ||
|
||
// Must access the parent to make an option select properly | ||
// Support: IE9, IE10 | ||
support.optSelected = opt.selected; | ||
|
||
// Make sure that the options inside disabled selects aren't marked as disabled | ||
// (WebKit marks them as disabled) | ||
select.disabled = true; | ||
support.optDisabled = !opt.disabled; | ||
|
||
// Check if an input maintains its value after becoming a radio | ||
// Support: IE9, IE10 | ||
input = document.createElement( "input" ); | ||
input.value = "t"; | ||
input.type = "radio"; | ||
support.radioValue = input.value === "t"; | ||
})(); | ||
|
||
return support; | ||
|
||
}); |
10 comments
on commit bbbdd94
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've missed where the tests are lazy (can't seem to find it), they look like they are all initialized once the module is loaded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit split up tests into their respective modules, but not all tests need to be lazy. The css module has examples of tests run lazily. Also, there are more in 1.x than 2.x.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@timmywil Thanks! In looking at the css module for 2+ it looks like the lazy call reliableMarginRight
is not caching its return value in reliableMarginRightVal
like others (it's v1 counterpart is though).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jdalton Some of the support tests work in conjunction with addGetHookIf
. This function attaches a get hook that calls the support function on its first call and then replaces itself with the appropriate result. Effectively, reliableMarginRight
is only called once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rad. So in that case the v1 counterpart doesn't need to cache its result (it's currently caching it) in reliableMarginRightVal
either?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jdalton agreed.
@mzgol Also, looking at the 1.x code. It seems setting some support values ahead of time, when computedStyleTests()
gets run first, ensures that the support tests never actually get run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jdalton Nice catch with reliableMarginRight
in 1.x! Thanks, I've missed it. The strategy of caching only those tests that are invoked more than once could backfire if the support test set changed frequently but it's pretty stable so I went for it.
@timmywil It's actually only a question of reliableMarginRight
as the rest is set just a few lines later:
https://github.com/jquery/jquery/blob/41523ae1d35b9023e9479b58c0fbe47269746411/src/css/support.js#L178-179
I guess we don't have a test that would force-compute boxSizingReliable
and after that reliableMarginRight
, otherwise it'd be caught. Not sure if it's worth adding a test for that, though - the number of potential combinations of order in which support tests are executed is quite high and once I remove the unneeded caching of this support test result, the problem will solve itself automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@timmywil BTW, why do we need to test boxSizing
via checking offsetWidth
, was some browser misbehaving? Looking at support tables: https://github.com/jquery/jquery/blob/master/test/unit/support.js it seems every browser that supports the box-sizing
property has true
there. In that case, it would be simpler to just check if the boxSizing
rule doesn't disappear. It would also allow to remove the jQuery.swap
workaround and would make it possible to run this test without attaching the div
to body
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
once I remove the unneeded caching of this support test result, the problem will solve itself automatically.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does this module depend on
../ajax
but doesn't use a reference to the module in the callback a line below? Is this related to the buildsystem?