aboutsummaryrefslogtreecommitdiffstats
path: root/src/support.js
diff options
context:
space:
mode:
authorGianni Chiappetta <gianni@runlevel6.org>2011-01-21 09:58:55 -0500
committerGianni Chiappetta <gianni@runlevel6.org>2011-01-21 09:58:55 -0500
commita03f040dbfb12da6409e31cb5923550d4be4a99e (patch)
tree4dfa1ed01b8e8c1e502097056e448d39642c0f1a /src/support.js
parentade531cfaa194eb13fa6307368d1e715f3be8326 (diff)
parent328a86f9a0d3f0907cc950f7543e34cb3efbda3f (diff)
downloadjquery-a03f040dbfb12da6409e31cb5923550d4be4a99e.tar.gz
jquery-a03f040dbfb12da6409e31cb5923550d4be4a99e.zip
Merge branch 'master' into proxy-native-bind
* master: (194 commits) Revert "Make sure that focusin/focusout bubbles in non-IE browsers." This was causing problems with the focusin event, see: #7340. Replaces "text in-between" technique with a full-fledged one-level transitive search for converters (unit tests added). Also cleans up auto dataType determination and adds converter checks in order to guess the best dataType possible. Moves determineResponse logic into main ajax callback. Puts responseXXX fields definitions into ajaxSettings. Removes misleading comment. Bring jQuery('#id') and jQuery('body') logic back into core (while leaving it in Sizzle at the same time). Was causing too much of a performance hit to leave it all to Sizzle. Renames Deferred's fire and fireReject methods as resolveWith and rejectWith respectively. Fix typo in regex tweak from previous commit. Renames determineDataType as determineResponse. Makes it more generic as a first step into integrating the logic into the main ajax done callback. Also fixes some comments in ajax/xhr.js. Move jQuery(...) selector speed-up logic into Sizzle(...) qSA handling. Additionally add in a new catch for Sizzle('.class') (avoid using qSA and use getElementsByClassName instead, where applicable). Revises the way arguments are handled in ajax. Makes sure statusCode callbacks are ordered in the same way success and error callbacks are. Unit tests added. Cleans up and simplifies code shared by ajaxPrefilter and ajaxTransport. Removes chainability of ajaxSetup, ajaxPrefilter and ajaxTransport. Also makes sure context is handled properly by ajaxSetup (unit test added). Rework unit tests to check actual result elements. Moves active counter test after all other ajax tests where it should be. Revised the Nokia support fallback. It turns out that Nokia supports the documentElement property but does not define document.compatMode. Adding this third fallback allows Nokia to run jQuery error-free and return proper values for window width and height. Moves things around to make jsLint happier. Fixes crossDomain test so that it assumes port to be 80 for http and 443 for https when it is not provided. Moves determineDataType into ajaxSettings so that it is accessible to transports without the need for a second argument and so that we can now pass the original options to the transport instead. Also ensures the original options are actually propagated to prefilters (they were not). Re-adds hastily removed variable and simplifies statusCode based callbacks handling. Use undefined instead of 0 to deference transport for clarity. ... Conflicts: src/event.js
Diffstat (limited to 'src/support.js')
-rw-r--r--src/support.js65
1 files changed, 42 insertions, 23 deletions
diff --git a/src/support.js b/src/support.js
index 55c19d80a..8adec5a0f 100644
--- a/src/support.js
+++ b/src/support.js
@@ -4,10 +4,7 @@
jQuery.support = {};
- var root = document.documentElement,
- script = document.createElement("script"),
- div = document.createElement("div"),
- id = "script" + jQuery.now();
+ var div = document.createElement("div");
div.style.display = "none";
div.innerHTML = " <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
@@ -68,7 +65,7 @@
deleteExpando: true,
optDisabled: false,
checkClone: false,
- scriptEval: false,
+ _scriptEval: null,
noCloneEvent: true,
boxModel: null,
inlineBlockNeedsLayout: false,
@@ -81,32 +78,46 @@
select.disabled = true;
jQuery.support.optDisabled = !opt.disabled;
- script.type = "text/javascript";
- try {
- script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
- } catch(e) {}
-
- root.insertBefore( script, root.firstChild );
+ jQuery.support.scriptEval = function() {
+ if ( jQuery.support._scriptEval === null ) {
+ var root = document.documentElement,
+ script = document.createElement("script"),
+ id = "script" + jQuery.now();
+
+ script.type = "text/javascript";
+ try {
+ script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
+ } catch(e) {}
+
+ root.insertBefore( script, root.firstChild );
+
+ // Make sure that the execution of code works by injecting a script
+ // tag with appendChild/createTextNode
+ // (IE doesn't support this, fails, and uses .text instead)
+ if ( window[ id ] ) {
+ jQuery.support._scriptEval = true;
+ delete window[ id ];
+ } else {
+ jQuery.support._scriptEval = false;
+ }
+
+ root.removeChild( script );
+ // release memory in IE
+ root = script = id = null;
+ }
- // Make sure that the execution of code works by injecting a script
- // tag with appendChild/createTextNode
- // (IE doesn't support this, fails, and uses .text instead)
- if ( window[ id ] ) {
- jQuery.support.scriptEval = true;
- delete window[ id ];
- }
+ return jQuery.support._scriptEval;
+ };
// Test to see if it's possible to delete an expando from an element
// Fails in Internet Explorer
try {
- delete script.test;
+ delete div.test;
} catch(e) {
jQuery.support.deleteExpando = false;
}
- root.removeChild( script );
-
if ( div.attachEvent && div.fireEvent ) {
div.attachEvent("onclick", function click() {
// Cloning a node shouldn't copy over any
@@ -151,7 +162,7 @@
jQuery.support.shrinkWrapBlocks = div.offsetWidth !== 2;
}
- div.innerHTML = "<table><tr><td style='padding:0;display:none'></td><td>t</td></tr></table>";
+ div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";
var tds = div.getElementsByTagName("td");
// Check if table cells still have offsetWidth/Height when they are set
@@ -181,6 +192,14 @@
var el = document.createElement("div");
eventName = "on" + eventName;
+ // We only care about the case where non-standard event systems
+ // are used, namely in IE. Short-circuiting here helps us to
+ // avoid an eval call (in setAttribute) which can cause CSP
+ // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
+ if ( !el.attachEvent ) {
+ return true;
+ }
+
var isSupported = (eventName in el);
if ( !isSupported ) {
el.setAttribute(eventName, "return;");
@@ -195,6 +214,6 @@
jQuery.support.changeBubbles = eventSupported("change");
// release memory in IE
- root = script = div = all = a = null;
+ div = all = a = null;
})();
})( jQuery );