From 13686ca257e1b087eb48b916e27483f4613e3ae6 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Mon, 11 Jun 2012 21:24:03 -0400 Subject: [PATCH] Don't use inline styles in support.js Instead apply them after we've parsed out a DOM. Content-Security-Policy forbids inline styles by default. Avoid triggering errors in sites wishing to adopt CSP. (Or in Chrome extensions, as they get it enabled by default.) This fixes bug #11249. --- src/support.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/support.js b/src/support.js index 65081e4..5f83e0d 100644 --- a/src/support.js +++ b/src/support.js @@ -14,10 +14,11 @@ jQuery.support = (function() { // Preliminary tests div.setAttribute( "className", "t" ); - div.innerHTML = "
a"; + div.innerHTML = "
a"; all = div.getElementsByTagName("*"); a = div.getElementsByTagName("a")[ 0 ]; + a.style.cssText = "top:1px;float:left;opacity:.5;"; // Can't get basic test support if ( !all || !all.length || !a ) { @@ -193,8 +194,9 @@ jQuery.support = (function() { // display:none (it is still safe to use offsets if a parent element is // hidden; don safety goggles and see bug #4512 for more information). // (only IE 8 fails this test) - div.innerHTML = "
t
"; + div.innerHTML = "
t
"; tds = div.getElementsByTagName("td"); + tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none"; isSupported = ( tds[ 0 ].offsetHeight === 0 ); tds[ 0 ].style.display = ""; @@ -240,7 +242,8 @@ jQuery.support = (function() { // (IE 6 does this) div.style.display = "block"; div.style.overflow = "visible"; - div.innerHTML = "
"; + div.innerHTML = "
"; + div.getElementsByTagName("div")[ 0 ].style.cssText = "width:5px;"; support.shrinkWrapBlocks = ( div.offsetWidth !== 3 ); container.style.zoom = 1; -- 1.7.10.2