From 0996e3d1534c9c05f485002cf7157981d1fcd85c 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: https://develop.svn.wordpress.org/trunk@22957 602fd350-edb4-49c9-b593-d223f7449a82 --- 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,