简体   繁体   中英

Where to report Javascript bugs?

Imagine this: You want to make some things with a XML element you receive in a method. So you try this:

function makeNiceThings(XMLDOM){
    if(XMLDOM.getElementsByTagName("err")){
        makeReallyNiceThings(XMLDOM.getElementsByTagName("err")[0].childNodes[0].nodeValue);
    }
}

So, Javascript tells you you're trying to call childNodes[0] from a null reference. But if you try:

  function makeNiceThings(XMLDOM){
        if(XMLDOM.getElementsByTagName("err")[0]){
            makeReallyNiceThings(XMLDOM.getElementsByTagName("err")[0].childNodes[0].nodeValue);
        }
    }

It works flawlessly.

However, you update the page sometimes, and both are working again, no problems at all.

I have already faces so many situations like this, that I really want to know if there is a place I can show these bizarre errors in order to make javascript even better. Google returned me nothing but places to discover programmer errors. Ideas?

Well, I don't see an issue there. In the first example you may get and empty array which is not nothing. So the condition becomes true. Whereas in the second example you do what you really meant to do — check if there's an element with index 0.
Or, if you are really convinced that this is not your fault, you should do what Rocket Hazmat said:

Bugs with JavaScript itself should be reported to the bug tracker of the browser. Though, chances are this is not a bug with JavaScript.

But most probably this is a mistake in the code. If there's no err elements, you'll get an empty array and the condition will be evaluated to true ; but there's no 0th element — that's why you get an exeption.
Hope that was clear.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM