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

feat: deprecate and replace dom.isVisible, utils.isHidden, and dom.isHiddenWithCss #3351

Merged
merged 39 commits into from
Sep 21, 2022

Conversation

straker
Copy link
Contributor

@straker straker commented Jan 14, 2022

A precursor to fixing #2806 and #3532.

Closes #3617

@straker straker requested a review from a team as a code owner January 14, 2022 18:33
Copy link
Contributor

@WilcoFiers WilcoFiers left a comment

Choose a reason for hiding this comment

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

The direction looks fine. I left some suggestions on refactoring this to make the logic of which method does what a little more explicit. Obviously I'd like to see tests added to this.

lib/commons/dom/is-visible.js Outdated Show resolved Hide resolved
lib/commons/dom/is-visible.js Outdated Show resolved Hide resolved
lib/commons/dom/is-visible.js Outdated Show resolved Hide resolved
lib/commons/dom/is-visible.js Outdated Show resolved Hide resolved
lib/commons/dom/is-visible.js Outdated Show resolved Hide resolved
lib/commons/dom/is-visible.js Outdated Show resolved Hide resolved
straker and others added 2 commits January 17, 2022 08:40
Co-authored-by: Wilco Fiers <WilcoFiers@users.noreply.github.com>
lib/commons/dom/is-visible.js Outdated Show resolved Hide resolved
lib/commons/dom/is-visible.js Outdated Show resolved Hide resolved
lib/commons/dom/is-visible.js Outdated Show resolved Hide resolved
lib/commons/dom/is-visible.js Outdated Show resolved Hide resolved
lib/commons/dom/is-visible.js Outdated Show resolved Hide resolved
lib/commons/dom/is-visible.js Outdated Show resolved Hide resolved
straker and others added 2 commits January 21, 2022 10:35
Co-authored-by: Wilco Fiers <WilcoFiers@users.noreply.github.com>
Co-authored-by: Wilco Fiers <WilcoFiers@users.noreply.github.com>
@straker straker changed the title chore: refactor isVisible [WIP] chore: refactor isVisible Feb 11, 2022
@straker straker changed the title [WIP] chore: refactor isVisible chore: refactor isVisible Jul 28, 2022
@straker straker changed the title chore: refactor isVisible refactor(isVisible): clean up function and put different visible checks into their own function Jul 28, 2022
lib/commons/dom/is-visible.js Outdated Show resolved Hide resolved
lib/commons/dom/is-visible.js Outdated Show resolved Hide resolved
lib/commons/dom/is-visible.js Outdated Show resolved Hide resolved
@straker straker changed the title refactor(isVisible): clean up function and put different visible checks into their own function [WIP] refactor(isVisible): clean up function and put different visible checks into their own function Aug 22, 2022
@straker straker changed the title [WIP] refactor(isVisible): clean up function and put different visible checks into their own function refactor(isVisible): clean up function and put different visible checks into their own function Aug 25, 2022
@straker straker marked this pull request as draft August 25, 2022 22:04
@straker straker dismissed a stale review via b9ad968 August 31, 2022 21:52
@straker straker changed the title refactor(isVisible): clean up function and put different visible checks into their own function feat: deprecate isVisible, isHidden, and isHiddenWithCss Use isVisibleOnScreen, isVisibleForScreenreader, and isHiddenForEveryone (respectively) Aug 31, 2022
straker and others added 3 commits September 8, 2022 13:59
Co-authored-by: Wilco Fiers <WilcoFiers@users.noreply.github.com>
Co-authored-by: Wilco Fiers <WilcoFiers@users.noreply.github.com>
@straker
Copy link
Contributor Author

straker commented Sep 8, 2022

All comments about changing things outside of the refactor captured here #3655

@straker
Copy link
Contributor Author

straker commented Sep 8, 2022

So although I converted the functions to use options, I don't think memoize can memoize options. Given the code:

foo = axe.utils.memoize(function(a, { b }) {
  console.log('here', {a, b})
  return true
})

foo(1, {b: 2}) // here {a: 1, b: 2}
foo(1, {b: 2}) // here {a: 1, b: 2}

Which shows that the memoized function is not be cached as the options object is not strictly equal for the cache to trigger. We may not be able to do options after all.

lib/commons/dom/is-offscreen.js Show resolved Hide resolved
@@ -0,0 +1,171 @@
import {
Copy link
Contributor

Choose a reason for hiding this comment

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

Disagree. I'm uncomfortable when we do it just for pulling a method into its own file. With whole new methods I think we need to make the effort. These are easy tests to write. Let's just get them done.

@WilcoFiers
Copy link
Contributor

Also remember to open an issue for those questionable uses of isVisible.

.eslintrc.js Outdated Show resolved Hide resolved
Copy link
Contributor

@WilcoFiers WilcoFiers left a comment

Choose a reason for hiding this comment

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

Couple minor points

lib/commons/dom/is-offscreen.js Show resolved Hide resolved
Comment on lines +95 to +107
axe._thisWillBeDeletedDoNotUse.commons =
axe._thisWillBeDeletedDoNotUse.commons || {};
axe._thisWillBeDeletedDoNotUse.commons.dom =
axe._thisWillBeDeletedDoNotUse.commons.dom || {};
axe._thisWillBeDeletedDoNotUse.commons.dom.nativelyHidden = nativelyHidden;
axe._thisWillBeDeletedDoNotUse.commons.dom.displayHidden = displayHidden;
axe._thisWillBeDeletedDoNotUse.commons.dom.visibilityHidden = visibilityHidden;
axe._thisWillBeDeletedDoNotUse.commons.dom.ariaHidden = ariaHidden;
axe._thisWillBeDeletedDoNotUse.commons.dom.opacityHidden = opacityHidden;
axe._thisWillBeDeletedDoNotUse.commons.dom.scrollHidden = scrollHidden;
axe._thisWillBeDeletedDoNotUse.commons.dom.overflowHidden = overflowHidden;
axe._thisWillBeDeletedDoNotUse.commons.dom.clipHidden = clipHidden;
axe._thisWillBeDeletedDoNotUse.commons.dom.areaHidden = areaHidden;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is getting messy. Lets pull this into a separate file.

Copy link
Contributor Author

@straker straker Sep 20, 2022

Choose a reason for hiding this comment

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

Added to the tech debt ticket #3655 (cleaning it up properly is out of scope for this pr as this object is in multiple places throughout the lib code base)

Copy link
Contributor

Choose a reason for hiding this comment

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

Your PR is increasing tech debt. That's not out of scope. But fine, under protest.

.eslintrc.js Outdated Show resolved Hide resolved
Comment on lines +95 to +107
axe._thisWillBeDeletedDoNotUse.commons =
axe._thisWillBeDeletedDoNotUse.commons || {};
axe._thisWillBeDeletedDoNotUse.commons.dom =
axe._thisWillBeDeletedDoNotUse.commons.dom || {};
axe._thisWillBeDeletedDoNotUse.commons.dom.nativelyHidden = nativelyHidden;
axe._thisWillBeDeletedDoNotUse.commons.dom.displayHidden = displayHidden;
axe._thisWillBeDeletedDoNotUse.commons.dom.visibilityHidden = visibilityHidden;
axe._thisWillBeDeletedDoNotUse.commons.dom.ariaHidden = ariaHidden;
axe._thisWillBeDeletedDoNotUse.commons.dom.opacityHidden = opacityHidden;
axe._thisWillBeDeletedDoNotUse.commons.dom.scrollHidden = scrollHidden;
axe._thisWillBeDeletedDoNotUse.commons.dom.overflowHidden = overflowHidden;
axe._thisWillBeDeletedDoNotUse.commons.dom.clipHidden = clipHidden;
axe._thisWillBeDeletedDoNotUse.commons.dom.areaHidden = areaHidden;
Copy link
Contributor

Choose a reason for hiding this comment

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

Your PR is increasing tech debt. That's not out of scope. But fine, under protest.

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.

Refactor multiple visibility functions
3 participants