I have this problem with Jquery items[c] is well defined as HTMLElement but when I use .find with more than one selector I get this error:
TypeError: X[g].exec is not a function
http://code.jquery.com/jquery-latest.min.js
when i checked some watches i got what is in the image below:
$(items[c]).find('.received')
works fine and returns some elements as there is elements with that class
$(items[c]).find('.receive')
works fine too and returns zero elements as there is no elements with that class.
but $(items[c]).find('.received.unseen')
returns undefined and bugs. so what is happening here?
EDIT: here is what is inside items[c], from the debugger firefox
EDIT: here is the function where i have the bug and i switched to jquery 2.1.1:
function updateUnseenBell(){
var m;
for (var c in items)
if (items.hasOwnProperty(c) && (m = items[c].gEbCN("chat-partner-tab")[0])) {
if($(items[c]).find('.received.unseen:not(.shown)').length > 0){
if (!(m.l2_newMsgBell)) {
m.appendChild(m.l2_newMsgBell = newMsgBell.cloneNode());
playSound("message");
}
} else if (m.l2_newMsgBell) {
m.removeChild(m.l2_newMsgBell);
delete m.l2_newMsgBell;
}
}
}
and i reduced it to this minimum for debug but still get the same error:
function updateUnseenBell(){
for (var c in items) {
if (items.hasOwnProperty(c)) {
if ($(items[c]).find('.received.unseen:not(.shown)').length > 0) {
alert(1);
} else {
alert(2);
}
}
}
}
Use
$(items[c]).find('.message.received.unseen')
and that should work.
One other way to solve this will be
$(items[c]).find(".received").find(".unseen").find(":not(.shown)")
Its not an elegant approach but works too.