id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc,blocking,blockedby
4534,2 instances of jQuery kills unbind,ptarjan,,"Steps to recreate :

 * http://paul.slowgeek.com/nodeSelector/dev/bad-unbind.html
 * Click the ""Add key listener""
 * Press keys and notice they are printed
 * Press ESC and see it says ""unbinding""
 * Press more keys and see they AREN'T printed
 * Click the ""add key listener"" again
 * Press keys and see they ARE printed
 * Press ESC and see it says ""unbinding""
 * Press keys and see they ARE printed (this is the bad part)



If I change the javascript code to NOT add the jQuery library, then it works as expected.

Pasting Code incase my site is down:

--- bad-unbind.html
<a href='
javascript:(
   function() { 
      var s=document.createElement(""script"");
          s.charset=""UTF-8"";
          s.src=""bad-unbind.js"";
      document.body.appendChild(s)
   })();
'>Add key listener</a>
<p id='key'></p>
--- end

--- bad-unbind.js
addLibs = function () {
    if (typeof(document.body) == ""undefined"" || document.body == null) {
        setTimeout(addLibs, 100);
        return;
    }

    // This line makes it work
    // if (typeof($) == ""undefined"") {
        node = document.createElement(""script"");
        node.src = ""http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"";
        document.body.appendChild(node);
    // }
    addEvents();
} 

addEvents = function () {  
    if (typeof($) == ""undefined"" || $(""*"") == null) {
        setTimeout(addEvents, 100);
        return;
    }
    var keydown = function(e) {
        if (e.keyCode == undefined && e.charCode != undefined) e.keyCode = e.charCode;
        $(""#key"").html(""keydown "" + e.keyCode);
        // Escape key
        if (e.keyCode == 27) {
            $(""#key"").html(""unbinding"");
            $(document).unbind(""keydown"", keydown);
        }
    };
    $(document).keydown(keydown);

}
addLibs();
--- end",bug,closed,major,1.4,unfiled,1.3.2,invalid,,,,
