Skip to content

Commit

Permalink
[#18671], Fix a11y issue for IE platform (#19037)
Browse files Browse the repository at this point in the history
* [#18671], Fix a11y issue for IE platform

* [#18671]: PR Feedback fix

Used tryFocus instead of element.focus

* [#18671]: Update implementation approach

* [#18671], Remove unused import
  • Loading branch information
sagarkbhatt authored and cvializ committed Oct 30, 2018
1 parent 36fd394 commit dd80243
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/service/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
escapeCssSelectorIdent,
isIframed,
openWindowDialog,
tryFocus,
} from '../dom';
import {dev, user} from '../log';
import {dict} from '../utils/object';
Expand Down Expand Up @@ -458,6 +459,19 @@ export class Navigation {
if (targetAttr != '_top' && targetAttr != '_blank') {
target.setAttribute('target', '_blank');
}
return; // bail early.
}

// Accessibility fix for IE browser
if (Services.platformFor(this.ampdoc.win).isIe()) {
const internalTargetElmId = tgtLoc.hash.substring(1);
const internalElm = this.ampdoc.getElementById(internalTargetElmId);
if (internalElm) {
if (!(/^(?:a|select|input|button|textarea)$/i.test(internalElm.tagName))) {
internalElm.tabIndex = -1;
}
tryFocus(internalElm);
}
}
return;
}
Expand Down

0 comments on commit dd80243

Please sign in to comment.