#151 ✓resolved
nickg

bugs ahoy in parser/htmldocument.js

Reported by nickg | April 13th, 2010 @ 05:10 PM

I'm just putting this in for the record. I have a patch momentarily.

in parser/htmldocument.js

__extend__(HTMLDocument.prototype,{
    open : function(){
        //console.log('opening doc for write.');                                                                 
        this._open = true;
        this._writebuffer = [];
    },
    close : function(){
        //console.log('closing doc.');                                                                           
        if(this._open){
            HTMLParser.parseDocument(this._writebuffer.join('\n'), this);
            this._open = false;
            this._writebuffer = null;
            //console.log('finished writing doc.');                                                              
        }
    },
    write: function(htmlstring) {
        //console.log('writing doc.');                                                                           
        if (this._open) {
            this._writebuffer = [htmlstring];
        }
    },
    writeln: function(htmlstring) {
        if (this.open) {
            this._writebuffer.push(htmlstring);
        }
    }

Bugs ahoy!

  • writeln Uses wrong test. Should be this._open
  • writeln Should append '\n' to writebuffer
  • writeln and write should implicitly call open if not done already
  • write erases the writebuffer on each call
  • close joins with newline, should be join with empty string

What's funny is that the bugs cancel each other out which is why unless you used plain 'write' you'd never notice.

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

a javascript browser environment

People watching this ticket

Pages