From e0809209ecc6cf76c342919c8fde7ef7124354cc Mon Sep 17 00:00:00 2001 From: Gabriel Wicke Date: Mon, 4 Jun 2012 12:26:03 +0200 Subject: [PATCH] Don't set the data-mw attribute if the object is actually empty. Change-Id: I984f1b44bba67d7a9f1a709738d14c0ee02f69a9 --- .../parser/mediawiki.HTML5TreeBuilder.node.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/parser/mediawiki.HTML5TreeBuilder.node.js b/modules/parser/mediawiki.HTML5TreeBuilder.node.js index a82bd94497..97ff63cccc 100644 --- a/modules/parser/mediawiki.HTML5TreeBuilder.node.js +++ b/modules/parser/mediawiki.HTML5TreeBuilder.node.js @@ -74,15 +74,15 @@ FauxHTML5.TreeBuilder.prototype._att = function (maybeAttribs) { FauxHTML5.TreeBuilder.prototype.processToken = function (token) { var attribs = token.attribs || []; if ( token.dataAttribs ) { - if ( ! token.attribs ) { - token.attribs = []; + var dataMW = JSON.stringify( token.dataAttribs ); + if ( dataMW !== '{}' ) { + attribs = attribs.concat([ + { + // Mediawiki-specific round-trip / non-semantic information + k: 'data-mw', + v: dataMW + } ] ); } - attribs = attribs.concat([ - { - // Mediawiki-specific round-trip / non-semantic information - k: 'data-mw', - v: JSON.stringify( token.dataAttribs ) - } ] ); } switch( token.constructor ) {