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

Unique IDs for a11y Elements #39

Merged
merged 7 commits into from
Jun 29, 2016
Merged

Unique IDs for a11y Elements #39

merged 7 commits into from
Jun 29, 2016

Conversation

jamesmartin
Copy link
Owner

Addresses #38. Generates a simple SHA1 hash of the title and description element's ID attributes to ensure uniqueness when adding the aria-labelled-by attribute to the SVG root node.

/cc @tysongach is this what you had in mind?

@jamesmartin
Copy link
Owner Author

Actually, thinking about it a bit more. SHA1 is going to be unsuitable for an ID because it can generate garbage like this:

irb(main):007:0> OpenSSL::Digest::SHA1.digest("some-value")
=> "\xC1\xB2B\x94\xF0\x0E(\x16\x05\xF9\xDDj)\x86\x12\xE3\x06\x00b\xB4"

I don't think we want that as an ID. Might have to switch to a random alpha/numeric generator.

@jamesmartin
Copy link
Owner Author

Worked around the SHA1 byte-garbage problem by hexencoding the bytes, converting to a base16 fixnum and then working back to base36 to get a-zA-Z0-9. Should be fine.

@tysongach
Copy link

Sounds great! Mind posting an example input/output?

@jamesmartin
Copy link
Owner Author

Mind posting an example input/output?

@tysongach here's an example from my test rails app:

  %h2 SVG With Accessibility Labels (Aria)
  .svg
    = inline_svg('iconmonstr-glasses-12-icon.svg', class: 'medium-blue', title: 'An SVG', desc: 'This is my SVG. There are many like it. You get the picture', aria: true)

screen shot 2016-06-29 at 4 09 58 pm


What do you think?

@tysongach
Copy link

@jamesmartin I think this is great!

@jamesmartin jamesmartin merged commit fba467e into master Jun 29, 2016
@jamesmartin jamesmartin deleted the unique-ids branch June 29, 2016 22:18
@jamesmartin jamesmartin added this to the 0.9.0 milestone Jun 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants