Created by: alpadev
fixes https://github.com/twbs/bootstrap/issues/32496, closes https://github.com/twbs/bootstrap/pull/32341
Background
Manipulator.offset() is using getBoundingClientRect() that returns top/left values relative to the viewport. The current implementation uses document.body.scrollTop and document.body.scrollLeft to get the scroll position of the viewport. (Both returning 0 in current Chrome and FF)
This used to work with older browsers but since then got changed to document.documentElement.scrollTop and document.documentElement.scrollLeft. The currently proposed way to get those values (according to MDN) is to use window.pageYOffset and window.pageXOffset.
TBD
-
Should we also add fallbacks for
window.pageYOffsetandwindow.pageXOffsetmentioned on the MDN page? -
Not sure about the test cases. Maybe someone got a better idea how to implement them.
Preview: https://deploy-preview-33603--twbs-bootstrap.netlify.app/docs/5.0/components/scrollspy/
Example of #32496 (closed) using the fix: https://codepen.io/-alpa-/pen/MWpVooG