Message info
 
To:wp-svn@lists.automattic.com From:m@wordpress.org Subject:[wp-svn] [20930] trunk/wp-includes/js/customize-preview.dev.js: Theme Customizer: Fix preview background CSS creation to insert/remove style nodes ( for IE8 compatibility). Date:Sat, 26 May 2012 07:02:28 +0000 (UTC)
 

Revision
20930
Author
koopersmith
Date
2012-05-26 07:02:28 +0000 (Sat, 26 May 2012)

Log Message

Theme Customizer: Fix preview background CSS creation to insert/remove style nodes (for IE8 compatibility). fixes #20582, see #19910.

Modified Paths

Diff

Modified: trunk/wp-includes/js/customize-preview.dev.js (20929 => 20930)


--- trunk/wp-includes/js/customize-preview.dev.js	2012-05-26 05:58:26 UTC (rev 20929)
+++ trunk/wp-includes/js/customize-preview.dev.js	2012-05-26 07:02:28 UTC (rev 20930)
@@ -81,7 +81,8 @@
 		});
 
 		api.when.apply( api, bg ).done( function( color, image, position_x, repeat, attachment ) {
-			var body  = $(document.body),
+			var body = $(document.body),
+				head = $('head'),
 				style = $('#custom-background-css'),
 				update;
 
@@ -90,10 +91,6 @@
 			if ( body.hasClass('custom-background') && ! style.length )
 				return;
 
-			// Create the CSS container if it doesn't already exist.
-			if ( ! style.length )
-				style = $('<style type="text/css" id="custom-background-css" />').appendTo('head');
-
 			update = function() {
 				var css = '';
 
@@ -113,7 +110,9 @@
 					css += 'background-position: top ' + attachment() + ';';
 				}
 
-				style.html( 'body.custom-background { ' + css + ' }' );
+				// Refresh the stylesheet by removing and recreating it.
+				style.remove();
+				style = $('<style type="text/css" id="custom-background-css">body.custom-background { ' + css + ' }</style>').appendTo( head );
 			};
 
 			$.each( arguments, function() {