|
4 | 4 |
|
5 | 5 | jQuery.support = {}; |
6 | 6 |
|
7 | | - var root = document.documentElement, |
8 | | - script = document.createElement("script"), |
9 | | - div = document.createElement("div"), |
10 | | - id = "script" + jQuery.now(); |
| 7 | + var div = document.createElement("div"); |
11 | 8 |
|
12 | 9 | div.style.display = "none"; |
13 | 10 | div.innerHTML = " <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>"; |
|
64 | 61 | deleteExpando: true, |
65 | 62 | optDisabled: false, |
66 | 63 | checkClone: false, |
67 | | - scriptEval: false, |
| 64 | + _scriptEval: null, |
68 | 65 | noCloneEvent: true, |
69 | 66 | boxModel: null, |
70 | 67 | inlineBlockNeedsLayout: false, |
|
77 | 74 | select.disabled = true; |
78 | 75 | jQuery.support.optDisabled = !opt.disabled; |
79 | 76 |
|
80 | | - script.type = "text/javascript"; |
81 | | - try { |
82 | | - script.appendChild( document.createTextNode( "window." + id + "=1;" ) ); |
83 | | - } catch(e) {} |
84 | | - |
85 | | - root.insertBefore( script, root.firstChild ); |
86 | | - |
87 | | - // Make sure that the execution of code works by injecting a script |
88 | | - // tag with appendChild/createTextNode |
89 | | - // (IE doesn't support this, fails, and uses .text instead) |
90 | | - if ( window[ id ] ) { |
91 | | - jQuery.support.scriptEval = true; |
92 | | - delete window[ id ]; |
93 | | - } |
| 77 | + jQuery.support.scriptEval = function() { |
| 78 | + if ( jQuery.support._scriptEval === null) { |
| 79 | + var root = document.documentElement, |
| 80 | + script = document.createElement("script"), |
| 81 | + id = "script" + jQuery.now(); |
| 82 | + |
| 83 | + script.type = "text/javascript"; |
| 84 | + try { |
| 85 | + script.appendChild( document.createTextNode( "window." + id + "=1;" ) ); |
| 86 | + } catch(e) {} |
| 87 | + |
| 88 | + root.insertBefore( script, root.firstChild ); |
| 89 | + |
| 90 | + // Make sure that the execution of code works by injecting a script |
| 91 | + // tag with appendChild/createTextNode |
| 92 | + // (IE doesn't support this, fails, and uses .text instead) |
| 93 | + if ( window[ id ] ) { |
| 94 | + jQuery.support._scriptEval = true; |
| 95 | + delete window[ id ]; |
| 96 | + } else { |
| 97 | + jQuery.support._scriptEval = false; |
| 98 | + } |
| 99 | + |
| 100 | + root.removeChild( script ); |
| 101 | + // release memory in IE |
| 102 | + root = script = id = null; |
| 103 | + } |
| 104 | + return jQuery.support._scriptEval; |
| 105 | + }; |
94 | 106 |
|
95 | 107 | // Test to see if it's possible to delete an expando from an element |
96 | 108 | // Fails in Internet Explorer |
97 | 109 | try { |
98 | | - delete script.test; |
| 110 | + delete div.test; |
99 | 111 |
|
100 | 112 | } catch(e) { |
101 | 113 | jQuery.support.deleteExpando = false; |
102 | 114 | } |
103 | 115 |
|
104 | | - root.removeChild( script ); |
105 | | - |
106 | 116 | if ( div.attachEvent && div.fireEvent ) { |
107 | 117 | div.attachEvent("onclick", function click() { |
108 | 118 | // Cloning a node shouldn't copy over any |
|
179 | 189 |
|
180 | 190 | var isSupported = (eventName in el); |
181 | 191 | if ( !isSupported ) { |
182 | | - el.setAttribute(eventName, "return;"); |
| 192 | + el.addEventListener(eventName, function() { return; }, true); |
183 | 193 | isSupported = typeof el[eventName] === "function"; |
184 | 194 | } |
185 | 195 | el = null; |
|
191 | 201 | jQuery.support.changeBubbles = eventSupported("change"); |
192 | 202 |
|
193 | 203 | // release memory in IE |
194 | | - root = script = div = all = a = null; |
| 204 | + div = all = a = null; |
195 | 205 | })(); |
196 | 206 | })( jQuery ); |
0 commit comments