From 1d46cdae08ea6ca19610f839a5f3709b24581dfe Mon Sep 17 00:00:00 2001 From: Subramanya Sastry Date: Thu, 26 Jul 2012 15:43:02 -0500 Subject: [PATCH] Minor: trace output tweak + code refactoring Change-Id: Ic8f51749e84edb7741f5bcea467d647682ef1958 --- modules/parser/ext.core.Sanitizer.js | 5 +++-- modules/parser/mediawiki.parser.defines.js | 13 +++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/modules/parser/ext.core.Sanitizer.js b/modules/parser/ext.core.Sanitizer.js index c691461833..4fa3373659 100644 --- a/modules/parser/ext.core.Sanitizer.js +++ b/modules/parser/ext.core.Sanitizer.js @@ -334,16 +334,17 @@ Sanitizer.prototype.onAny = function ( token ) { if ( token.attribs && token.attribs.length ) { var attribs = token.attribs.slice(); var newToken = $.extend( {}, token ); + var env = this.manager.env; for ( var i = 0, l = attribs.length; i < l; i++ ) { var kv = attribs[i], k = kv.k, v = kv.v; if ( k.constructor === Array ) { - k = this.manager.env.tokensToString ( k ); + k = env.tokensToString ( k ); } if ( v.constructor === Array ) { - v = this.manager.env.tokensToString ( v ); + v = env.tokensToString ( v ); } if ( k === 'style' ) { v = this.checkCss(v); diff --git a/modules/parser/mediawiki.parser.defines.js b/modules/parser/mediawiki.parser.defines.js index 705980ac14..259ff579c0 100644 --- a/modules/parser/mediawiki.parser.defines.js +++ b/modules/parser/mediawiki.parser.defines.js @@ -94,9 +94,18 @@ TagTk.prototype.tagToStringFns = { } }; -TagTk.prototype.toString = function() { +TagTk.prototype.toString = function(compact) { if (this.dataAttribs.stx && this.dataAttribs.stx === "html") { - return ""; + if (compact) { + return ""; + } else { + var buf = []; + for (var i = 0, n = this.attribs.length; i < n; i++) { + var a = this.attribs[i]; + buf.push(Util.toStringTokens(a.k).join('') + "=" + Util.toStringTokens(a.v).join('')); + } + return ""; + } } else { var f = this.tagToStringFns[this.name]; return f ? f.bind(this)() : this.defaultToString();