When fetching in media/views/embed/link.js, call abort() on any existing XHRs.

Use `$.ajax` instead of `wp.ajax.send()` to allow this.
Pass `this` as `context` to the options to remove the need to bind callbacks.

Fixes #32035.

Built from https://develop.svn.wordpress.org/trunk@32460


git-svn-id: http://core.svn.wordpress.org/trunk@32430 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2015-05-08 19:16:25 +00:00
parent 31f46f5363
commit af326241ff
3 changed files with 20 additions and 9 deletions

View File

@ -4561,28 +4561,39 @@ EmbedLink = wp.media.view.Settings.extend({
return;
}
if ( this.dfd && 'pending' === this.dfd.state() ) {
this.dfd.abort();
}
embed = new wp.shortcode({
tag: 'embed',
attrs: _.pick( this.model.attributes, [ 'width', 'height', 'src' ] ),
content: this.model.get('url')
});
wp.ajax.send( 'parse-embed', {
data : {
this.dfd = $.ajax({
type: 'POST',
url: wp.ajax.settings.url,
context: this,
data: {
action: 'parse-embed',
post_ID: wp.media.view.settings.post.id,
shortcode: embed.string()
}
} )
.done( _.bind( this.renderoEmbed, this ) )
.fail( _.bind( this.renderFail, this ) );
})
.done( this.renderoEmbed )
.fail( this.renderFail );
},
renderFail: function () {
renderFail: function ( response, status ) {
if ( 'abort' === status ) {
return;
}
this.$( '.link-text' ).show();
},
renderoEmbed: function( response ) {
var html = ( response && response.body ) || '';
var html = ( response && response.data && response.data.body ) || '';
if ( html ) {
this.$('.embed-container').show().find('.embed-preview').html( html );

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.3-alpha-32459';
$wp_version = '4.3-alpha-32460';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.