Bug Tracker

Ticket #10178 (closed bug: fixed)

Opened 3 years ago

Last modified 2 years ago

$(window).is("a") >> Uncaught TypeError: Cannot call method 'toLowerCase' of undefined

Reported by: ronny@… Owned by: timmywil
Priority: low Milestone: 1.7
Component: selector Version: 1.6.2
Keywords: Cc:
Blocking: Blocked by:

Description

 http://jsfiddle.net/k4nz6/

$(window).is("a") throws a uncaught exception

Change History

comment:1 Changed 3 years ago by timmywil

  • Priority changed from undecided to low
  • Component changed from unfiled to traversing

I'm inclined to say don't call .is() on a window. There isn't really a useful result that can be given in this case since windows cannot be selected with a selector. I'll let someone else on the team weigh in before closing.

comment:2 Changed 3 years ago by timmywil

  • Owner set to timmywil
  • Status changed from new to assigned
  • Component changed from traversing to selector
  • Milestone changed from None to 1.7

Spoke to rwaldron. This is probably easy enough to fix and I can think of at least one case where it would be nice to have this fail silently. That is, if window is part of a larger set and the set is being filtered. Assigning to myself as this is an issue in sizzle.

comment:3 Changed 3 years ago by anonymous

Easy fix, l.4352 should be:

-return (match === "*" && elem.nodeType === 1) +return (match === "*" && elem.nodeType === 1)
elem.nodeName.toLowerCase() === match;
(elem.nodeName && elem.nodeName.toLowerCase() === match);

It was broken for elements which does not have a "nodeName" property.

comment:4 Changed 3 years ago by timmywil

  • Status changed from assigned to closed
  • Resolution set to fixed

Override Sizzle attribute retrieval with jQuery.attr. Fixes #5637, #7128, #9261, #9570, #10178.

Bug fixed on the side: $(window).is('a') was throwing an exception. Fixes #10178.

Changeset: 92405d4f5ffe9ec1f26f280303783014948438c5

Note: See TracTickets for help on using tickets.