#999 bug
Dan Dean

Event.findElement causes error if nothing matches the given pattern

Reported by Dan Dean | March 1st, 2010 @ 05:38 PM | in After 1.7

I've copied this issue over from the GitHub issue tracker for this project. We should really disable that so people don't accidentally post issues there.

I've marked it as high priority since it is a request related to Rails 3 Prototype-UJS. The complete content of the ticket is below.


If you call Event.findElement with a pattern that doesn't match any elements in the ancestor chain, you get an error (in Chrome and FF) caused by getAttribute() being called on the root HTML document object, which doesn't have a getAttribute method. It is easily reproducible:

  function clickme(event) {
    try {
      alert(event.findElement('[bogus-attr]'));
    } catch(e) {
      alert(e);
    }
  }

<a href="#" onclick="clickme(event)">Click me!</a>

For now, I'm working around this by putting a try/catch around findElement calls.

Comments and changes to this ticket

  • Tobie Langel

    Tobie Langel March 1st, 2010 @ 06:04 PM

    • Assigned user set to “Tobie Langel”
    • Milestone set to 1.7

    That's a Sizzle bug, I'm afraid:

    Prototype.Selector.match(window, '[dd]');
    >>> TypeError: Result of expression 'elem.getAttribute' [undefined] is not a function.
    
    Prototype.Selector.engine.matches('[dd]', [window]);
    >>> TypeError: Result of expression 'elem.getAttribute' [undefined] is not a function.
    

    Could you please report it to Sizzle and link back their ticket to this one?

  • Andrew Dupont

    Andrew Dupont October 17th, 2010 @ 09:17 AM

    • Milestone changed from 1.7 to After 1.7
    • Importance changed from “” to “Low”

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins

Pages