Skip to content

Event.findElement causes error if nothing matches the given pattern #4

Closed

Description

@jamis

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:

<script type="text/javascript" src="/javascripts/prototype.js"></script> <script type="text/javascript"> function clickme(event) { try { alert(event.findElement('[bogus-attr]')); } catch(e) { alert(e); } } </script> Click me!

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

Activity

  1. dandean commented on Mar 1, 2010

    @dandean
    Contributor

    Hi Jamis,

    Wouldn't the correct selector be event.findElement('*[bogus-attr]').

    In any event, I'm going to move this report over to the lighthouse. Thanks!

  2. dandean commented on Mar 1, 2010

    @dandean
    Contributor

    Jamis, you can track progress on this issue here:

    https://prototype.lighthouseapp.com/projects/8886-prototype/tickets/999

    Please post any future issues over on the lighthouse project.

  3. jamis commented on Mar 1, 2010

    @jamis
    Author

    Oh, didn't know about '*[blah]'. I guess I figured if the syntax was invalid, the selector would have failed earlier. :) Thanks for moving it to lighthouse, wasn't sure where the right place to report this was.

  4. tobie commented on Mar 1, 2010

    @tobie
    Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions