Index: branches/REL1_18/phase3/resources/mediawiki/mediawiki.js |
— | — | @@ -1133,9 +1133,17 @@ |
1134 | 1134 | * Returns <div><img src="<"/></div> |
1135 | 1135 | */ |
1136 | 1136 | this.element = function( name, attrs, contents ) { |
1137 | | - var s = '<' + name; |
| 1137 | + var v, s = '<' + name; |
1138 | 1138 | for ( var attrName in attrs ) { |
1139 | | - s += ' ' + attrName + '="' + this.escape( attrs[attrName] ) + '"'; |
| 1139 | + v = attrs[attrName]; |
| 1140 | + // Convert name=true, to name=name |
| 1141 | + if ( v === true ) { |
| 1142 | + v = attrName; |
| 1143 | + // Skip name=false |
| 1144 | + } else if ( v === false ) { |
| 1145 | + continue; |
| 1146 | + } |
| 1147 | + s += ' ' + attrName + '="' + this.escape( '' + v ) + '"'; |
1140 | 1148 | } |
1141 | 1149 | if ( contents === undefined || contents === null ) { |
1142 | 1150 | // Self close tag |
— | — | @@ -1144,20 +1152,29 @@ |
1145 | 1153 | } |
1146 | 1154 | // Regular open tag |
1147 | 1155 | s += '>'; |
1148 | | - if ( typeof contents === 'string' ) { |
1149 | | - // Escaped |
1150 | | - s += this.escape( contents ); |
1151 | | - } else if ( contents instanceof this.Raw ) { |
1152 | | - // Raw HTML inclusion |
1153 | | - s += contents.value; |
1154 | | - } else if ( contents instanceof this.Cdata ) { |
1155 | | - // CDATA |
1156 | | - if ( /<\/[a-zA-z]/.test( contents.value ) ) { |
1157 | | - throw new Error( 'mw.html.element: Illegal end tag found in CDATA' ); |
1158 | | - } |
1159 | | - s += contents.value; |
1160 | | - } else { |
1161 | | - throw new Error( 'mw.html.element: Invalid type of contents' ); |
| 1156 | + switch ( typeof contents ) { |
| 1157 | + case 'string': |
| 1158 | + // Escaped |
| 1159 | + s += this.escape( contents ); |
| 1160 | + break; |
| 1161 | + case 'number': |
| 1162 | + case 'boolean': |
| 1163 | + // Convert to string |
| 1164 | + s += '' + contents; |
| 1165 | + break; |
| 1166 | + default: |
| 1167 | + if ( contents instanceof this.Raw ) { |
| 1168 | + // Raw HTML inclusion |
| 1169 | + s += contents.value; |
| 1170 | + } else if ( contents instanceof this.Cdata ) { |
| 1171 | + // CDATA |
| 1172 | + if ( /<\/[a-zA-z]/.test( contents.value ) ) { |
| 1173 | + throw new Error( 'mw.html.element: Illegal end tag found in CDATA' ); |
| 1174 | + } |
| 1175 | + s += contents.value; |
| 1176 | + } else { |
| 1177 | + throw new Error( 'mw.html.element: Invalid type of contents' ); |
| 1178 | + } |
1162 | 1179 | } |
1163 | 1180 | s += '</' + name + '>'; |
1164 | 1181 | return s; |
Property changes on: branches/REL1_18/phase3 |
___________________________________________________________________ |
Modified: svn:mergeinfo |
1165 | 1182 | Merged /trunk/phase3:r96307,96310 |