-
Notifications
You must be signed in to change notification settings - Fork 124
Add older IE support #10
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
Conversation
src/focus-ring.js
Outdated
| _addClass = function(el, htmlClass) { | ||
| el.className += ' '+htmlClass; | ||
| }, | ||
| _removeClass = function(el, htmlClass) { |
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.
Do you know the support level of RegExp in older IE? It might be nicer to do something like:
this.element.className = this.element.className.replace(regExp(name), '');
based on the polyfill example in https://developer.mozilla.org/en-US/docs/Web/API/Element/classList#Polyfill
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.
Good call! I've snagged the regex helper function from the classList Polyfill and followed their lead. Feels cleaner :) (And because I'll never understand Regex :) ha!)
src/focus-ring.js
Outdated
| } | ||
| return triggers; | ||
| }, | ||
| _addClass = function(el, htmlClass) { |
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.
because we're declaring these inside of a function I don't think you need to underscore their names
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.
Sounds good - I've removed those underscores :)
src/focus-ring.js
Outdated
| document.body.addEventListener('keydown', function() { | ||
| hadKeyboardEvent = true; | ||
| if (document.activeElement.matches(':focus')) { | ||
| if (document.activeElement) { |
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.
This change seems ok to me. cc @alice for a 2nd opinion
… helper functions forEach - regex
|
Hey @joe-watkins, could you join the WICG in order to appease the IPR bots? Thanks! |
|
@joe-watkins potentially helpful link: https://www.w3.org/community/wicg/participants |
|
@robdodson This branch is way off from from gh-pages, different worlds,.. and merge conflicts are pretty gnarly. I've signed up over at WICG (tnx @yoavweiss !) which may help w/future PRs. I'm going to pull latest |
Hi :)
I've tweaked the Polyfill to reach back a bit further with IE.
.gitignorefilefocus-ring,data-focus-ring-addedindexOf()instead of.contains('focus-ring')_addClass()&_removeClass()helper functions to replaceel.classList.add()&el.classList.remove().matches(':focus')method on line 58 -- no old IE support and felt redundant.