r96305 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96304‎ | r96305 | r96306 >
Date:21:25, 5 September 2011
Author:krinkle
Status:ok
Tags:
Comment:
mediawiki.html: Add broken tests for numbers and booleans
* The following are broken right now:

mw.html.element( 'p', {}, 500 );
> Error: mw.html.element: Invalid type of contents
(custom error by mw.html.element)

mw.html.element( 'option', { selected: foo === bar }, 'label' );
> TypeError: Undefined method .replace

(bug 30774) - mediawiki.html: Add support for numbers and booleans
Modified paths:
  • /trunk/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.test.js (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.test.js
@@ -170,7 +170,7 @@
171171 });
172172
173173 test( 'mw.html', function() {
174 - expect(7);
 174+ expect(11);
175175
176176 raises( function(){
177177 mw.html.escape();
@@ -184,11 +184,41 @@
185185
186186 equal( mw.html.element( 'div' ), '<div/>', 'html.element DIV (simple)' );
187187
188 - equal( mw.html.element( 'div',
189 - { id: 'foobar' } ),
 188+ equal(
 189+ mw.html.element(
 190+ 'div', {
 191+ id: 'foobar'
 192+ }
 193+ ),
190194 '<div id="foobar"/>',
191195 'html.element DIV (attribs)' );
192196
 197+ equal( mw.html.element( 'p', null, 12 ), '<p>12</p>', 'Numbers are valid content and should be casted to a string' );
 198+
 199+ equal( mw.html.element( 'p', { title: 12 }, '' ), '<p title="12"></p>', 'Numbers are valid attribute values' );
 200+
 201+ equal(
 202+ mw.html.element(
 203+ 'option', {
 204+ value: 'foo',
 205+ selected: true
 206+ }, 'Foo'
 207+ ),
 208+ '<option value="foo" selected="selected">Foo</option>',
 209+ 'Attributes may have boolean values. True copies the attribute name to the value.'
 210+ );
 211+
 212+ equal(
 213+ mw.html.element(
 214+ 'option', {
 215+ value: 'foo',
 216+ selected: false
 217+ }, 'Foo'
 218+ ),
 219+ '<option value="foo">Foo</option>',
 220+ 'Attributes may have boolean values. False keeps the attribute from output.'
 221+ );
 222+
193223 equal( mw.html.element( 'div',
194224 null, 'a' ),
195225 '<div>a</div>',

Follow-up revisions

RevisionCommit summaryAuthorDate
r96307mediawiki.html: mediawiki.html: Add support for numbers and booleans...krinkle21:51, 5 September 2011
r96321* (bug 29916) add follow-up fetching to CR API...reedy11:31, 6 September 2011

Status & tagging log