According to jQuery and our MediaWiki style guide all kinds of
$( '<element>' )
$( '<element/>' )
$( '<element />' )
$( '<element></element>' )
are identical. So yes, all this patch does is removing characters
that are ignored anyway. Using the same style everywhere makes the
code easier to read and understand and may save a few bytes when it
is gzipped.
The current core/resources/ folder contains 148 jQuery calls of
that kind. Only this file (plus some jQuery plugins I don't want to
touch) do not use the most simple <element> style.
Plus:
* Added some line breaks.
* Fixed broken inline documentation.
Change-Id: I080716f21f2ab95164a9ca241a4ce4fc351e0b55
* Decodes the main HTML entities, those encoded by mw.html.escape.
*
* @private
* Decodes the main HTML entities, those encoded by mw.html.escape.
*
* @private
- * @param {string} encode Encoded string
+ * @param {string} encoded Encoded string
* @return {string} String with those entities decoded
*/
function decodePrimaryHtmlEntities( encoded ) {
* @return {string} String with those entities decoded
*/
function decodePrimaryHtmlEntities( encoded ) {
* If there was an error parsing, return the key and the error message (wrapped in jQuery). This should put the error right into
* the interface, without causing the page to halt script execution, and it hopefully should be clearer how to fix it.
* @private
* If there was an error parsing, return the key and the error message (wrapped in jQuery). This should put the error right into
* the interface, without causing the page to halt script execution, and it hopefully should be clearer how to fix it.
* @private
- * @param {Object} parser options
+ * @param {Object} options Parser options
* @return {Function}
* @return {Array} return.args First element is the key, replacements may be in array in 2nd element, or remaining elements.
* @return {jQuery} return.return
* @return {Function}
* @return {Array} return.args First element is the key, replacements may be in array in 2nd element, or remaining elements.
* @return {jQuery} return.return
if ( parsedCloseTagResult === null ) {
// Closing tag failed. Return the start tag and contents.
if ( parsedCloseTagResult === null ) {
// Closing tag failed. Return the start tag and contents.
- return [ 'CONCAT', input.substring( startOpenTagPos, endOpenTagPos ) ].concat( parsedHtmlContents );
+ return [ 'CONCAT', input.substring( startOpenTagPos, endOpenTagPos ) ]
+ .concat( parsedHtmlContents );
wrappedAttributes = parsedOpenTagResult[2];
attributes = wrappedAttributes.slice( 1 );
if ( isAllowedHtml( startTagName, endTagName, attributes ) ) {
wrappedAttributes = parsedOpenTagResult[2];
attributes = wrappedAttributes.slice( 1 );
if ( isAllowedHtml( startTagName, endTagName, attributes ) ) {
- result = [ 'HTMLELEMENT', startTagName, wrappedAttributes ].concat( parsedHtmlContents );
+ result = [ 'HTMLELEMENT', startTagName, wrappedAttributes ]
+ .concat( parsedHtmlContents );
} else {
// HTML is not allowed, so contents will remain how
// it was, while HTML markup at this level will be
} else {
// HTML is not allowed, so contents will remain how
// it was, while HTML markup at this level will be
// parsed HTML link.
//
// Concatenate everything from the tag, flattening the contents.
// parsed HTML link.
//
// Concatenate everything from the tag, flattening the contents.
- result = [ 'CONCAT', input.substring( startOpenTagPos, endOpenTagPos ) ].concat( parsedHtmlContents, input.substring( startCloseTagPos, endCloseTagPos ) );
+ result = [ 'CONCAT', input.substring( startOpenTagPos, endOpenTagPos ) ]
+ .concat( parsedHtmlContents, input.substring( startCloseTagPos, endCloseTagPos ) );
curlyBraceTransformExpressionLiteral
] );
curlyBraceTransformExpressionLiteral
] );
/**
* htmlEmitter - object which primarily exists to emit HTML from parser ASTs
*/
/**
* htmlEmitter - object which primarily exists to emit HTML from parser ASTs
*/
/**
* (We put this method definition here, and not in prototype, to make sure it's not overwritten by any magic.)
* Walk entire node structure, applying replacements and template functions when appropriate
/**
* (We put this method definition here, and not in prototype, to make sure it's not overwritten by any magic.)
* Walk entire node structure, applying replacements and template functions when appropriate
- * @param {Mixed} abstract syntax tree (top node or subnode)
+ * @param {Mixed} node Abstract syntax tree (top node or subnode)
* @param {Array} replacements for $1, $2, ... $n
* @return {Mixed} single-string node or array of nodes suitable for jQuery appending
*/
* @param {Array} replacements for $1, $2, ... $n
* @return {Mixed} single-string node or array of nodes suitable for jQuery appending
*/
// For everything in input that follows double-open-curly braces, there should be an equivalent parser
// function. For instance {{PLURAL ... }} will be processed by 'plural'.
// If you have 'magic words' then configure the parser to have them upon creation.
// For everything in input that follows double-open-curly braces, there should be an equivalent parser
// function. For instance {{PLURAL ... }} will be processed by 'plural'.
// If you have 'magic words' then configure the parser to have them upon creation.
* TODO: Throw error if nodes.length > 1 ?
*
* @param {Array} nodes List of one element, integer, n >= 0
* TODO: Throw error if nodes.length > 1 ?
*
* @param {Array} nodes List of one element, integer, n >= 0
- * @param {Array} replacements
+ * @param {Array} replacements List of at least n strings
* @return {String} replacement
*/
replace: function ( nodes, replacements ) {
* @return {String} replacement
*/
replace: function ( nodes, replacements ) {
- return $( '<a />' ).attr( {
+ return $( '<a>' ).attr( {
title: page,
href: url
} ).text( anchor );
title: page,
href: url
} ).text( anchor );
* TODO: throw error if nodes.length > 1 ?
*
* @param {Array} nodes List of one element, integer, n >= 0
* TODO: throw error if nodes.length > 1 ?
*
* @param {Array} nodes List of one element, integer, n >= 0
+ * @param {Array} replacements List of at least n strings
* @return {string} replacement
*/
extlinkparam: function ( nodes, replacements ) {
* @return {string} replacement
*/
extlinkparam: function ( nodes, replacements ) {