[Jslib] A bug in RDFContainer.getNode()?

Pete Collins pete at mozdevgroup.com
Thu Apr 28 17:11:25 EDT 2005



Wei Wang wrote:

>Greetings,
>
>Following is the function in JSlib 0.1.278:
>
>RDFContainer.prototype.getNode = function(aNode) {
>  var rv = null;
>  if(this.isValid()) {
>    var res = this.RDF.GetResource(this.subject+":"+aNode);
>    if(res) {
>      return new RDFResource("node", this.subject+":"+aNode, this.subject, this.dsource);
>    }
>  } else {
>      jslibError(null, "RDFContainer is no longer valid!\n", "NS_ERROR_UNEXPECTED",
>            JS_RDFCONTAINER_FILE+":getNode");
>    return null;
>  }
>};
>
>
>Shouldn't the "return null;" be put before the end bracket of the
>function? Also, the variable "rv" is not used.
>
>Regards,
>  
>
That code needs cleanup. I haven't gotten to it.

I'll take any patches if you feel inspired ... 

It should look something like this:

RDFContainer.prototype.getNode = function (aNode)
{
  var rv = null;
  if (this.isValid()) {
    var res = this.RDF.GetResource(this.subject+":"+aNode);
    if (res)
      rv = new RDFResource("node", this.subject+":"+aNode, this.subject, 
this.dsource);
    else
      rv = jslibErrorMsg("NS_ERROR_UNEXPECTED");
  }
 
  return rv;
};

-- 
Pete Collins - Founder, Mozdev Group Inc.
www.mozdevgroup.com
Mozilla Software Development Solutions 




More information about the Jslib mailing list