Bartosz Dziewoński has uploaded a new change for review.
https://gerrit.wikimedia.org/r/271549
Change subject: Avoid parsing HTML when creating <input> nodes
......................................................................
Avoid parsing HTML when creating <input> nodes
We used to create them like $( '<input type="checkbox" />' ), which
actually does HTML parsing under the hood, because on IE 8 and lower
trying to change the 'type' of an <input> node throws an exception.
But we dropped support for IE 8 recently and no longer need to do that.
Didn't touch any places where we otherwise do a lot of HTML parsing.
Change-Id: Ie136c427c49d83bb6aefe49b9aaad9dbec65ef16
---
M resources/handlers/mw.ApiUploadHandler.js
M resources/mw.UploadWizardLicenseInput.js
M resources/mw.UploadWizardUploadInterface.js
3 files changed, 5 insertions(+), 12 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard
refs/changes/49/271549/1
diff --git a/resources/handlers/mw.ApiUploadHandler.js
b/resources/handlers/mw.ApiUploadHandler.js
index 9a51628..5fb50c2 100644
--- a/resources/handlers/mw.ApiUploadHandler.js
+++ b/resources/handlers/mw.ApiUploadHandler.js
@@ -87,7 +87,7 @@
*/
addFormInputIfMissing: function ( name, value ) {
if ( this.$form.find( '[name="' + name + '"]' ).length
=== 0 ) {
- this.$form.append( $( '<input type="hidden" />'
) .attr( { name: name, value: value } ) );
+ this.$form.append( $( '<input>' ) .attr( {
type: 'hidden', name: name, value: value } ) );
}
},
diff --git a/resources/mw.UploadWizardLicenseInput.js
b/resources/mw.UploadWizardLicenseInput.js
index 9e327a7..a598476 100644
--- a/resources/mw.UploadWizardLicenseInput.js
+++ b/resources/mw.UploadWizardLicenseInput.js
@@ -261,17 +261,9 @@
name: this.name, // name of input,
shared among all checkboxes or radio buttons.
type: this.type, // kind of input
value:
this.createInputValueFromTemplateConfig( templates, config )
- },
+ };
- inputHtml = '<input ' +
- $.map( attrs, function ( val, key ) {
- return key + '="' +
val.toString().replace( '"', '' ) + '"';
- } ).join( ' ' ) +
- ' />';
-
- // Note we aren't using $('<input>').attr( { ... } ) .
We construct a string of HTML.
- // IE6 is idiotic about radio buttons; you have to
create them as HTML or clicks aren't recorded
- return $( inputHtml ).click( function () {
+ return $( '<input>' ).attr( attrs ).click( function () {
input.emit( 'change' );
} );
},
diff --git a/resources/mw.UploadWizardUploadInterface.js
b/resources/mw.UploadWizardUploadInterface.js
index 43cf415..ca83998 100644
--- a/resources/mw.UploadWizardUploadInterface.js
+++ b/resources/mw.UploadWizardUploadInterface.js
@@ -599,6 +599,7 @@
'class': 'mwe-upwiz-objref-pick-image'
} ),
attributes = {
+ type: 'checkbox',
'class': 'imgPicker',
id: 'imgPicker' + index,
disabled: false,
@@ -612,7 +613,7 @@
}
$fieldContainer.append(
- $( '<input type="checkbox">' ).attr( attributes ).on(
'click', function () {
+ $( '<input>' ).attr( attributes ).on( 'click', function
() {
$( this )
.prop( 'checked', true )
.closest( '.mwe-upwiz-file' )
--
To view, visit https://gerrit.wikimedia.org/r/271549
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie136c427c49d83bb6aefe49b9aaad9dbec65ef16
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits