jquery / learn.jquery.com

jQuery Learning Center web site content
https://learn.jquery.com
Other
924 stars 484 forks source link

CSS selector escape function should escape foward slashes #758

Closed schlimmchen closed 7 years ago

schlimmchen commented 7 years ago

I am using id attributes with values containing forward slash characters: '/'.

The function presented in https://github.com/jquery/learn.jquery.com/blob/master/page/using-jquery-core/faq/how-do-i-select-an-element-by-an-id-that-has-characters-used-in-css-notation.md should also escape forward slashes, which seems neccessary for the seletor to work:

return "#" + id.replace(/(\/|:|\.|\[|\]|,|=|@)/g, "\\$1")

dmethvin commented 7 years ago

As of jQuery 3.0 you could also use https://api.jquery.com/jQuery.escapeSelector/ .

Would you like to do a pull request with changes?

schlimmchen commented 7 years ago

Would you like to do a pull request with changes?

Well yes, now I did. Took me a while to assign this any priority, but now I'd like my pull request to be discussed and hopefully merged :)