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

Passing a dom element as the selector throws error #2

Open
shidhincr opened this issue Mar 19, 2018 · 2 comments
Open

Passing a dom element as the selector throws error #2

shidhincr opened this issue Mar 19, 2018 · 2 comments
Labels
good first issue Issues good enough for new contributors. help wanted

Comments

@shidhincr
Copy link
Contributor

Assume the following code:

import {$} from 'dollarDom'

const domElement = document.getElementById('#someElementID');
console.log(domElement); // This prints the dom element

$(domElement).on('click', function() { alert(this.innerHTML) }); // throws error

The above code throws the error:

screen shot 2018-03-19 at 11 53 55 am

Issue:

the $ method is not checking the type of the selector -- so ideally, it should check if the selector is a string or a dom node before calling the .trim() / or other actions on the selector.

@shidhincr shidhincr added the good first issue Issues good enough for new contributors. label Mar 19, 2018
@ndajr
Copy link

ndajr commented May 17, 2018

Assuming you intend to use DolarDOM, why would you use the getElementById? Why not $('#someElementID').on('click ... ?

@shidhincr
Copy link
Contributor Author

Sometimes, there are chances that people pass the entire DOM element as the selector. ( Mostly anyone who comes from the jQuery background would've done that ).

Ideally, we need to handle that situation gracefully, instead of the code throwing the unhandled exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Issues good enough for new contributors. help wanted
Projects
None yet
Development

No branches or pull requests

2 participants