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

Aria describedby tooltip 13480 #13557

Merged
merged 1 commit into from
May 23, 2014

Conversation

bassettsj
Copy link
Contributor

Pull request for issue #13480

@cvrebert
Copy link
Collaborator

cvrebert commented May 9, 2014

I would advise not including the *.min.js files, as they tend to cause merge conflicts.


Tooltip.prototype.setAriaDescribedBy = function() {
var tipId = this.uid(this.type)
this.$tip.attr('id',tipId )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please ensure that there's a space after all commas in your code

@cvrebert cvrebert added the js label May 9, 2014
@bassettsj
Copy link
Contributor Author

@cvrebert cleaned up the code from your feedback, thanks. I can squash the commits down if we need to as well.

Tooltip.prototype.uid = function (prefix) {
var id = prefix + Math.floor( Math.random() * 1000000 )

while ($('#' + id).length) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should use document.getElementById here for speed? I'll leave that for @fat to decide.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that makes sense, we don't too slow down much from adding more DOM queries.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont think we'd get much speed value given sizzle's code paths, but the code would probably look cleaner

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tooltip.prototype.uid = function (id) {
   do (id +=  Math.floor(Math.random() * 1000000)); while (document.getElementById(id))
   return id
}

@cvrebert
Copy link
Collaborator

cvrebert commented May 9, 2014

Yes, please squash if you're comfortable doing so.

@bassettsj
Copy link
Contributor Author

How does that look now, I am a little puzzle why it is including your two commits @cvrebert, if you don't mind fixing the history as it should I would be thankful.

@fat
Copy link
Member

fat commented May 10, 2014

im a little torn because i'd like to see a global accessibility plugin (something like we have for animation), which handles things like uid generation (which will likely be needed by other plugins as we continue work on accessibility).

That said, if we're only using it here, it's probably fine for now


Tooltip.prototype.setAriaDescribedBy = function() {
var tipId = this.$tip.attr('id', this.uid(this.type))
this.$element.attr('aria-describedby', tipId)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.$element.attr('aria-describedby', this.$tip.attr('id', this.uid(this.type)))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.$element.attr('aria-describedby', this.$tip.attr('id', this.uid(this.type)))
I tried using this at first, but it would return the DOM object in the ``... this.$tip.attr('id', this.uid(this.type)))`

@bassettsj
Copy link
Contributor Author

All good feedback @fat, I will make those changes and resubmit in a moment.

Regarding making the unique id function global, that could be helpful in the future. Being able to relate elements using aria-[whatever] is pretty common, so it might be helpful later.

@@ -147,8 +147,13 @@
var that = this;

var $tip = this.tip()
var tipId = this.type

do (tipId += Math.floor(Math.random() * 1000000)); while (document.getElementById(tipId))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that it would really matter, but

do tipId += ~~(Math.random() * 1000000)
while (document.getElementById(tipId))

does the same, requires no semicolon and double bitwise NOT performs slightly better than Math.floor. Also, it is shorter in the minified JS.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ha sounds good, thx

@bassettsj
Copy link
Contributor Author

Here we go, hopefully I got it this time. I think I integrated all the feedback. The only think I am wondering about is if the test coverage is good enough?

@hnrch02
Copy link
Collaborator

hnrch02 commented May 13, 2014

The concatenated JS is outdated, probably would be best to remove it completely from the PR.

@cvrebert
Copy link
Collaborator

I'll be happy to properly rebase this when merging it. Just need @fat to approve the final draft.

Generates a unique id for tooltip and adds [aria-describedby] to the element
it is called on. Resolves issue twbs#13480

- set up test
- linted the code styles
- passed the tests
- integrated feedback from @cvrebert
@bassettsj
Copy link
Contributor Author

@cvrebert @fat rebased off the latest master to prevent it from getting stale.

@cvrebert cvrebert added this to the v3.2.0 milestone May 16, 2014
@fat
Copy link
Member

fat commented May 23, 2014

changes lgtm

@bassettsj
Copy link
Contributor Author

Sorry What is lgtm?

@cvrebert
Copy link
Collaborator

"looks good to me"

@cvrebert
Copy link
Collaborator

Now running Sauce tests: https://travis-ci.org/twbs/bootstrap/jobs/25905569

@cvrebert
Copy link
Collaborator

Sauce test passed. Merging per @fat's LGTM.

@mdo mdo mentioned this pull request May 23, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants