Commenting code. Normally a good thing, right (the views of those crazy XP people notwithstanding)?
You wouldn’t have thought that adding comments could actually stop your code working, could you? Yet I’ve been writing XBL recently, and hit not one but two situations where exactly that happened.
In XBL, you write a binding which represents a widget, and you can then write methods to call on any element which you’ve bound that binding to. So you can do something like myWidget.throb(). If you want to use your method to fiddle with the anonymous content of your widget, the usual pattern used to get hold of it is:
var rootNode = document.getAnonymousNodes(this);
However, if you add a comment at the start of the <content>, node 0 is now a comment node, and all your methods stop working.
Secondly, and perhaps more seriously, I’ve just debugged a crash I started getting, and it turns out that some of the code in nsXBLPrototypeBinding.cpp, which is invoked when you change an XBL attribute via the DOM, doesn’t cope very well with comment nodes (it doesn’t check a return value for null). Removing all my comments prevents the crash. In other words, Mozilla crashed because I had commented my code too well…