r86956 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86955‎ | r86956 | r86957 >
Date:17:43, 26 April 2011
Author:maxsem
Status:ok
Tags:
Comment:
switched select() to use mw.html.element()
Modified paths:
  • /trunk/extensions/ApiSandbox/ext.apiSandbox.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ApiSandbox/ext.apiSandbox.js
@@ -128,28 +128,25 @@
129129 }
130130
131131 function select( values, attributes, selected ) {
132 - var s = '<select class="api-sandbox-input"';
 132+ attributes['class'] = 'api-sandbox-input';
133133 if ( isset( attributes.multiple ) ) {
134 - s += ' size="' + values.length + '"';
 134+ attributes['size'] = values.length.toString();
135135 }
136 - for ( var a in attributes ) {
137 - s += ' ' + a + '="' + attributes[a] + '"';
138 - }
139 - s += '>';
 136+ var s = '';
140137 if ( typeof selected != 'array' ) {
141138 if ( selected ) {
142 - s += '\n<option value="" selected="selected">' + mw.msg( 'apisb-select-value' ) + '</option>';
 139+ s += mw.html.element( 'option', { value: '', selected: 'selected' }, mw.msg( 'apisb-select-value' ) );
143140 }
144141 selected = [];
145142 }
146143 for ( var i = 0; i < values.length; i++ ) {
147 - s += '\n<option value="' + values[i] + '"';
 144+ var attrs = { value: values[i] };
148145 if ( $.inArray( values[i], selected ) >= 0 ) {
149 - s += ' selected="selected"';
 146+ attrs.selected = 'selected';
150147 }
151 - s += '>' + values[i] + '</option>';
 148+ s += '\n' + mw.html.element( 'option', attrs, values[i] );
152149 }
153 - s += '\n</select>';
 150+ s = mw.html.element( 'select', attributes, new mw.html.Raw( s ) );
154151 return s;
155152 }
156153

Status & tagging log