Revert default tokenization result from null to ''

* As part of an earlier fix, I had changed default value of 'res'
  to null instead of ''.  But, this was potentially buggy because
  the previous check was (res !== '') which could be triggered
  by return values of handlers.  By changing the check to null,
  I was effectively changing the code paths for those handlers that
  returned ''.

Change-Id: I2302023be7422ce4fb384ff5a50fe53fa7732855
This commit is contained in:
Subramanya Sastry 2012-06-13 11:53:05 -05:00
parent cfe94eed1f
commit 445780b4d3

View file

@ -401,11 +401,11 @@ WSP._serializeToken = function ( state, token ) {
case TagTk:
case SelfclosingTagTk:
handler = WSP.getTokenHandler(state, token);
res = handler.start ? handler.start( state, token ) : null;
res = handler.start ? handler.start( state, token ) : '';
break;
case EndTagTk:
handler = WSP.getTokenHandler(state, token);
res = handler.end ? handler.end( state, token ) : null;
res = handler.end ? handler.end( state, token ) : '';
break;
case String:
res = state.textHandler ? state.textHandler( token ) : token;
@ -417,15 +417,15 @@ WSP._serializeToken = function ( state, token ) {
res = '\n';
break;
case EOFTk:
res = null;
res = '';
break;
default:
res = null;
res = '';
console.warn( 'Unhandled token type ' + JSON.stringify( token ) );
break;
}
//console.warn( 'res: ' + JSON.stringify( res ) );
if (res) {
if (res !== '') {
var nls = res.match( /(?:\r?\n)+$/ );
if ( nls ) {
if ( nls[0] === res ) {