IE (7 tested) seems to be treating some strings more equal than others.
The following example demonstrates:
<html debug="true">
<head>
<script type="text/javascript" src="javascripts/prototype.js"></script>
<script src="javascripts/firebug/firebug.js" type="text/javascript"></script>
<script type="text/javascript">
Event.observe( window, "load", function() {
// Expected results:
// "" :: true
// undefined
// undefined
// "hi" :: true
// undefined
// a#hi
// Actual results:
// "" :: true
// undefined
// Error -- (invalid argument)
// "hi" :: true
// undefined
// a#hi
['hi', 'bye'].each( function(id) {
try {
console.debug('%o :: %o',
$(id).target,
Object.isString( $(id).target ) );
console.debug( $("") );
console.debug( $( $(id).target ) );
} catch(e) {
console.debug(e);
}
});
});
</script>
</head>
<body>
<a id="hi">Hello</a>
<a id="bye" target="hi">Good-bye</a>
</body>
</html>
The error occurs because document.getElementById is being called on what seems to be an empty string (Object.isString says it's a string) but IE considers it invalid. As you can see sending an empty string doesn't cause the same error, just sending it an empty string you got off an attribute that doesn't exist (it's the existence of the attribute -- a blank attribute works without error).
This was found to be not working in Prototype 1.6.0.1. But considering the way the bug works, it's probably present in trunk as well as several previous releases.