Skip to content

Commit

Permalink
perf(get-element-stack): improve getElementStack performance on large…
Browse files Browse the repository at this point in the history
… pages (#4026)

* perf(get-element-stack): improve getElementStack performance on large pages

* use memoize instead of cache in getScroll
  • Loading branch information
qazwsxedcrfvtgb1111 authored May 30, 2023
1 parent 6850af8 commit 0e73be0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/core/utils/get-scroll.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import memoize from './memoize';

/**
* Get the scroll position of given element
* @method getScroll
* @memberof axe.utils
* @param {Element} node
* @param {Element} elm
* @param {buffer} (Optional) allowed negligence in overflow
* @returns {Object | undefined}
*/
export default function getScroll(elm, buffer = 0) {
function getScroll(elm, buffer = 0) {
const overflowX = elm.scrollWidth > elm.clientWidth + buffer;
const overflowY = elm.scrollHeight > elm.clientHeight + buffer;

Expand Down Expand Up @@ -38,3 +40,5 @@ function isScrollable(style, prop) {
const overflowProp = style.getPropertyValue(prop);
return ['scroll', 'auto'].includes(overflowProp);
}

export default memoize(getScroll);

1 comment on commit 0e73be0

@Otero2
Copy link

@Otero2 Otero2 commented on 0e73be0 Jun 4, 2023

Choose a reason for hiding this comment

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

help Ive been hacked!!!!!!

Please sign in to comment.