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

Scrollspy Doesn't Support Chinese ID Targets #10205

Closed
wzpan opened this issue Aug 27, 2013 · 8 comments
Closed

Scrollspy Doesn't Support Chinese ID Targets #10205

wzpan opened this issue Aug 27, 2013 · 8 comments

Comments

@wzpan
Copy link

wzpan commented Aug 27, 2013

Hello, I found Scrollspy doesn't support Chinese ID Targets.

In order to reproduce the bug, I post a gist. It looks almost the same to the example from official Doc. A slight difference is that I modify one element's id("mdo") into a Chinese ID ("艾姆滴欧").

When you view the html file in your browser, you can see that it can spy all the target elements except that element with Chinese ID.

@cvrebert
Copy link
Collaborator

Sorry, we no longer support v2.x.x. You can ask for help on the mailing list though; see the README for a link.

@wzpan
Copy link
Author

wzpan commented Aug 27, 2013

To avoid raising a duplicate issue I will reply this one directly. The problem still exists in 3.0.
I've updated a new revision of this gist by using twitter-bootstrap 3.0. And the problem still remains.
Please check it again.

@cvrebert
Copy link
Collaborator

Please remove the docs CSS and upgrade the example to a JS Bin or JSFiddle.

@cvrebert cvrebert reopened this Aug 27, 2013
@wzpan
Copy link
Author

wzpan commented Aug 27, 2013

Done. Here's the example on JS Bin: http://jsbin.com/evETOjA/6/edit?html,output

@boulox
Copy link
Contributor

boulox commented Aug 27, 2013

Confirm came across this too, with Thai character

@ianb
Copy link

ianb commented Sep 5, 2013

Is this all due to https://github.com/twbs/bootstrap/blob/master/js/scrollspy.js#L61 : var $href = /^#\w/.test(href) && $(href) ? That is, \w won't match Chinese or other characters.

@wzpan
Copy link
Author

wzpan commented Sep 17, 2013

Thanks @ianb , it should be that reason! I have fixed it by extending the regexp so as to match Chinese and other characters and that works!

var $href = /^#[\u2e80-\u9fff\w]/.test(href) && $(href)

@boulox , please check whether Thai characters also works.

@fat
Copy link
Member

fat commented Dec 24, 2013

hm… yeah this was written with the old html4 stuff in mind http://www.w3.org/TR/html4/types.html#type-id

ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").

looks like html5 is much more chill with diff chars in id's tho http://mathiasbynens.be/notes/html5-id-class

i'll push a fix in the next few min

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

No branches or pull requests

5 participants