-
-
Notifications
You must be signed in to change notification settings - Fork 382
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
Use id attribute instead of name for ToC #111
Conversation
id = text.downcase | ||
id.gsub!(PUNCTUATION_REGEXP, '') # remove punctuation | ||
id.gsub!(' ', '-') # replace spaces with dash | ||
id = EscapeUtils.escape_uri(id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hoping @jakedouglas or @brianmario can review this change. The escape utils called was removed in #64. It seems like nokogiri did some magic with the name
attribute, but won't for the id
.
Oh dang! That is really unfortunate. This is going to cause trouble with user content clashing with IDs used by the app. See github/markup#219 (comment) Does HTML5 define any way for creating anchors to user-generated content without the potential of conflicting with the app? IMHO, |
Gah, I really wish we could prefix these. Another issue with This can introduce other JS bugs. Mainly around feature detecting. Say you added a |
Still can't merge as is. We're discussing some sort of prefixing solution. |
Why oh why oh why hasn't IE died in a 🔥 yet? |
Closing for now. Thinking about a different approach. |
Yeah we can't let people inject IDs in the page. But we also can't break everyones URLs w/ fragment identifiers by prefixing all the headings. If we prefix, we need to handle old fragment identifiers in JS and perform scrolling manually. Not sure I want us to go down that road—another browser feature reinvented. |
The
name
attribute is no longer considered a global attribute or part of thea
element as of the XHTML/HTML5 spec.id
has replaced this deprecated usage of thename
attribute.name
is now reserved only for "form controls".Related
a
element - http://www.w3.org/TR/html5/text-level-semantics.html#the-a-elementid
attribute - http://www.w3.org/TR/html5/dom.html#the-id-attributename
attribute - http://www.w3.org/TR/html5/forms.html#naming-form-controls:-the-name-attributecc @jch @raganwald @mislav