Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jamis opened this issue Mar 1, 2010 · 4 comments
Closed

Comments

@jamis
Copy link

jamis commented Mar 1, 2010

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.

@dandean
Copy link
Contributor

dandean commented Mar 1, 2010

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!

@dandean
Copy link
Contributor

dandean commented Mar 1, 2010

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.

@jamis
Copy link
Author

jamis commented Mar 1, 2010

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.

@tobie
Copy link
Collaborator

tobie commented Mar 1, 2010

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

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants