Media: Change upload button to a file input for better e2e targeting.
Changes the media library upload button to `input type="file"` for better end to end testing capabilities. Props justinahinon, joedolson, sabernhardt, audrasjb. Fixes #54168. Built from https://develop.svn.wordpress.org/trunk@52059 git-svn-id: http://core.svn.wordpress.org/trunk@51651 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -2858,16 +2858,21 @@ UploaderInline = View.extend(/** @lends wp.media.view.UploaderInline.prototype *
|
||||
$placeholder;
|
||||
|
||||
if ( this.controller.uploader ) {
|
||||
$placeholder = this.$('.browser');
|
||||
$placeholder = this.$('.browser-container');
|
||||
|
||||
// Check if we've already replaced the placeholder.
|
||||
if ( $placeholder[0] === $browser[0] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$browser.detach().text( $placeholder.text() );
|
||||
$browser[0].className = $placeholder[0].className;
|
||||
$browser[0].setAttribute( 'aria-labelledby', $browser[0].id + ' ' + $placeholder[0].getAttribute('aria-labelledby') );
|
||||
var browserLabel = $placeholder.find( 'label' );
|
||||
var browserInput = $placeholder.find( 'input' );
|
||||
|
||||
browserLabel.attr( 'for', $browser[0].id );
|
||||
browserInput.attr( 'id', $browser[0].id );
|
||||
$browser.removeAttr( 'id' );
|
||||
|
||||
$browser.append( browserLabel ).append( browserInput );
|
||||
$placeholder.replaceWith( $browser.show() );
|
||||
}
|
||||
|
||||
@@ -6334,7 +6339,7 @@ UploaderWindow = wp.media.View.extend(/** @lends wp.media.view.UploaderWindow.pr
|
||||
initialize: function() {
|
||||
var uploader;
|
||||
|
||||
this.$browser = $( '<button type="button" class="browser" />' ).hide().appendTo( 'body' );
|
||||
this.$browser = $( '<div class="browser-container">' ).hide().appendTo( 'body' );
|
||||
|
||||
uploader = this.options.uploader = _.defaults( this.options.uploader || {}, {
|
||||
dropzone: this.$el,
|
||||
|
||||
2
wp-includes/js/media-views.min.js
vendored
2
wp-includes/js/media-views.min.js
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user