From af42700ebd5834c250030abd8e5349e1bb3c14ef Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Fri, 30 Nov 2012 16:45:43 +0000 Subject: [PATCH] Resolve race conditions in Attachments.more(). Props koopersmith fixes #22656 git-svn-id: http://core.svn.wordpress.org/trunk@22957 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/js/media-views.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/wp-includes/js/media-views.js b/wp-includes/js/media-views.js index 72b952b002..acd25c2642 100644 --- a/wp-includes/js/media-views.js +++ b/wp-includes/js/media-views.js @@ -3071,11 +3071,17 @@ } }, + removeContent: function() { + _.each(['attachments','uploader'], function( key ) { + if ( this[ key ] ) { + this[ key ].remove(); + delete this[ key ]; + } + }, this ); + }, + createUploader: function() { - if ( this.attachments ) { - this.attachments.remove(); - delete this.attachments; - } + this.removeContent(); this.uploader = new media.view.UploaderInline({ controller: this.controller @@ -3085,10 +3091,7 @@ }, createAttachments: function() { - if ( this.uploader ) { - this.uploader.remove(); - delete this.uploader; - } + this.removeContent(); this.attachments = new media.view.Attachments({ controller: this.controller,