Don't set the data-mw attribute if the object is actually empty.

Change-Id: I984f1b44bba67d7a9f1a709738d14c0ee02f69a9
This commit is contained in:
Gabriel Wicke 2012-06-04 12:26:03 +02:00
parent 2774e5aa6c
commit e0809209ec

View file

@ -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 ) {