Add another tweak for handling CSP - we need to make sure that we don't trigger any...
[jquery.git] / src / support.js
index f502811..7be28fd 100644 (file)
@@ -75,7 +75,7 @@
        jQuery.support.optDisabled = !opt.disabled;
 
        jQuery.support.scriptEval = function() {
-               if ( jQuery.support._scriptEval === null) {
+               if ( jQuery.support._scriptEval === null ) {
                        var root = document.documentElement,
                                script = document.createElement("script"),
                                id = "script" + jQuery.now();
                        // release memory in IE
                        root = script = id  = null;
                }
+
                return jQuery.support._scriptEval;
        };
 
                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;");