-
Notifications
You must be signed in to change notification settings - Fork 788
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: deprecate and replace dom.isVisible, utils.isHidden, and dom.is…
…HiddenWithCss (#3351) * replace with dom.isVisibleOnScreen, dom.isVisibleForScreenreader, and dom.isHiddenForEveryone (respectively) * chore: refactor isVisible * comment * fix firefox * Update lib/commons/dom/is-visible.js Co-authored-by: Wilco Fiers <WilcoFiers@users.noreply.github.com> * update per suggestions * Update lib/commons/dom/is-visible.js Co-authored-by: Wilco Fiers <WilcoFiers@users.noreply.github.com> * Update lib/commons/dom/is-visible.js Co-authored-by: Wilco Fiers <WilcoFiers@users.noreply.github.com> * fixes * revert changes * is-hidden-for-everyone * functions done * revert files * fix lint * finish refactor * missed * fixes * revert files * finish tests * fix polyfill * fix test * Update lib/commons/dom/is-modal-open.js Co-authored-by: Wilco Fiers <WilcoFiers@users.noreply.github.com> * suggestions * Update lib/commons/dom/visibility-functions.js Co-authored-by: Wilco Fiers <WilcoFiers@users.noreply.github.com> * suggestions * suggestions * memoize correctly * memoize for real this time * uni tests * guard * reset eslintrc * merge * changes * fix lint Co-authored-by: Wilco Fiers <WilcoFiers@users.noreply.github.com>
1 parent
280815e
commit 1ae2ac0
Showing
51 changed files
with
2,073 additions
and
269 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import { isVisible, isOffscreen } from '../../commons/dom'; | ||
import { isVisibleOnScreen, isOffscreen } from '../../commons/dom'; | ||
|
||
function isOnScreenEvaluate(node) { | ||
// From a visual perspective | ||
return isVisible(node, false) && !isOffscreen(node); | ||
return isVisibleOnScreen(node) && !isOffscreen(node); | ||
} | ||
|
||
export default isOnScreenEvaluate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import AbstractVirtualNode from '../../core/base/virtual-node/abstract-virtual-node'; | ||
import { getNodeFromTree } from '../../core/utils'; | ||
import memoize from '../../core/utils/memoize'; | ||
import { | ||
nativelyHidden, | ||
displayHidden, | ||
visibilityHidden | ||
} from './visibility-methods'; | ||
|
||
const hiddenMethods = [displayHidden, visibilityHidden]; | ||
|
||
/** | ||
* Determine if an element is hidden from screenreaders and visual users | ||
* @method isHiddenForEveryone | ||
* @memberof axe.commons.dom | ||
* @param {VirtualNode} vNode The Virtual Node | ||
* @param {Object} [options] | ||
* @param {Boolean} [options.skipAncestors] If the ancestor tree should be not be used | ||
* @param {Boolean} [options.isAncestor] If this function is being called on an ancestor for the target node | ||
* @return {Boolean} The element's visibility state | ||
*/ | ||
export default function isHiddenForEveryone( | ||
vNode, | ||
{ skipAncestors, isAncestor = false } = {} | ||
) { | ||
vNode = vNode instanceof AbstractVirtualNode ? vNode : getNodeFromTree(vNode); | ||
|
||
if (skipAncestors) { | ||
return isHiddenSelf(vNode, isAncestor); | ||
} | ||
|
||
return isHiddenAncestors(vNode, isAncestor); | ||
} | ||
|
||
/** | ||
* Check the element for visibility state | ||
*/ | ||
const isHiddenSelf = memoize(function isHiddenSelfMemoized(vNode, isAncestor) { | ||
if (nativelyHidden(vNode)) { | ||
return true; | ||
} | ||
|
||
if (!vNode.actualNode) { | ||
return false; | ||
} | ||
|
||
if (hiddenMethods.some(method => method(vNode, { isAncestor }))) { | ||
return true; | ||
} | ||
|
||
// detached node | ||
if (!vNode.actualNode.isConnected) { | ||
return true; | ||
} | ||
|
||
return false; | ||
}); | ||
|
||
/** | ||
* Check the element and ancestors for visibility state | ||
*/ | ||
const isHiddenAncestors = memoize(function isHiddenAncestorsMemoized( | ||
vNode, | ||
isAncestor | ||
) { | ||
if (isHiddenSelf(vNode, isAncestor)) { | ||
return true; | ||
} | ||
|
||
if (!vNode.parent) { | ||
return false; | ||
} | ||
|
||
return isHiddenAncestors(vNode.parent, true); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.