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

Specific id selector doesnt work #281

Closed
HauntedSmores opened this issue Nov 10, 2017 · 8 comments
Closed

Specific id selector doesnt work #281

HauntedSmores opened this issue Nov 10, 2017 · 8 comments
Assignees
Labels

Comments

@HauntedSmores
Copy link

HauntedSmores commented Nov 10, 2017

Working on a project where a couple of SVG group elements have id's of "mom" and "dad".

For whatever reason id="dad" just does not work. Very strange - heres a fiddle with regular <div>'s reproducing the problem.

https://jsfiddle.net/cw1Lk5qq/4

@alexchantastic
Copy link
Contributor

alexchantastic commented Nov 10, 2017

Haha what weird bug. You can use document.getElementById('dad') instead as the target as a workaround for now.

The issue is because the selectString function thinks #dad is a color so it's not returning the selector properly.

@HauntedSmores
Copy link
Author

@alexchantastic Wow, never would have thought of that ha. Would it be better to use querySelectorAll instead of selectString?

@alexchantastic
Copy link
Contributor

selectString leverages querySelectorAll, but it first checks if what was passed in was a color. I'm not actually sure why though... maybe @juliangarnier can answer that.

@HauntedSmores
Copy link
Author

Ah okay, that makes sense. I just switched it to a class, but its an interesting edge case.

@juliangarnier
Copy link
Owner

I think it's legacy code from 1.x, looking at the code I don't think it's needed anymore.
Will look into this for the next release.
Thanks for reporting this!

@juliangarnier juliangarnier self-assigned this Nov 10, 2017
@HauntedSmores
Copy link
Author

@juliangarnier Happy to help!

@juliangarnier
Copy link
Owner

Should be fixed in V3 !

@VulumeCode
Copy link

It might be useful to print the error message. I thought I had this same issue, but it turns out you can't simply use an id starting with a number in a CSS selector. There's a workaround, using [id="10"], but that's not the point cause of course you shouldn't be fixing that for the user.

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

No branches or pull requests

4 participants