Skip to content

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

@jamis

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.

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