MarkTraceur has uploaded a new change for review.
https://gerrit.wikimedia.org/r/86803
Change subject: jquery audit of mw.ApiUploadHandler.js
......................................................................
jquery audit of mw.ApiUploadHandler.js
Bug: 53245
Change-Id: I1d426505328298af14e449e99477b8fe7d4313b8
---
M resources/mw.ApiUploadHandler.js
1 file changed, 16 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard
refs/changes/03/86803/1
diff --git a/resources/mw.ApiUploadHandler.js b/resources/mw.ApiUploadHandler.js
index 358cc57..9171306 100644
--- a/resources/mw.ApiUploadHandler.js
+++ b/resources/mw.ApiUploadHandler.js
@@ -21,6 +21,16 @@
this.upload = upload;
this.api = api;
this.$form = $( this.upload.ui.form );
+
+ // Shortcut object for checking existence of input elements
+ this.$formInputs = {};
+
+ // Initialise
+ this.$form.find( 'input' ).each( function ( i, input ) {
+ var $input = $( input );
+ handler.$formInputs[$input.prop( 'name' )] = $input;
+ } );
+
this.configureForm();
this.transport = new mw.IframeTransport(
@@ -84,8 +94,12 @@
* @param value the value of the input
*/
addFormInputIfMissing: function( name, value ) {
- if ( this.$form.find( '[name="' + name + '"]' ).length === 0 ) {
- this.$form.append( $( '<input type="hidden" />' )
.attr( { 'name': name, 'value': value } ));
+ if ( this.$formInputs[name] === undefined ) {
+ this.$formInputs[name] = $( '<input>' )
+ .prop( 'type', 'hidden' )
+ .prop( 'name', name )
+ .val( value );
+ this.$form.append( this.$formInputs[name] );
}
},
--
To view, visit https://gerrit.wikimedia.org/r/86803
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1d426505328298af14e449e99477b8fe7d4313b8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: MarkTraceur <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits