diff --git a/wp-includes/js/customize-preview.dev.js b/wp-includes/js/customize-preview.dev.js
index 36c4a6a858..1aef6aa232 100644
--- a/wp-includes/js/customize-preview.dev.js
+++ b/wp-includes/js/customize-preview.dev.js
@@ -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 = $('').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 = $('').appendTo( head );
};
$.each( arguments, function() {