-
Notifications
You must be signed in to change notification settings - Fork 341
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
Tweak tab clicks to use event.currentTarget
#3248
Conversation
src/govuk/components/tabs/tabs.mjs
Outdated
*/ | ||
Tabs.prototype.onTabClick = function (event) { | ||
if (!event.target.classList.contains('govuk-tabs__tab')) { |
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.
We've removed as event.currentTarget
will be the tab link (not a child element)
We know the IE8 polyfill adds event.currentTarget
support but just need to verify if it's clever enough to handle target vs currentTarget (might just alias them as the same thing)
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.
Yep from our polyfill
event.currentTarget = element;
event.relatedTarget = event.fromElement || null;
event.target = event.target || event.srcElement || element;
Where element is this
(current target)
We can skip our checks for “child DOM elements” on `event.target` by getting the tab link from `event.currentTarget` instead
629211a
to
a323c91
Compare
Might be worth updating the PR title and description to avoid confusion. |
event.currentTarget
and share handlersevent.currentTarget
A few minor tweaks to Tabs to simplify our code in places
Find the tab link using
event.currentTarget
Prevents us having to check for child elements getting the click
Move Tab bound handlers to constructorWe were recreating handlers multiple times per tabUpdate: Commit for 2) has been merged via: