File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -229,6 +229,14 @@ function alignNearest(
229229 return 0
230230}
231231
232+ function getParentElement ( element : Node ) : Element | null {
233+ const parent = element . parentElement ;
234+ if ( parent == null ) {
235+ return ( element . getRootNode ( ) as ShadowRoot ) . host || null ;
236+ }
237+ return parent ;
238+ }
239+
232240export default ( target : Element , options : Options ) : CustomScrollAction [ ] => {
233241 //TODO: remove this hack when microbundle will support typescript >= 4.0
234242 const windowWithViewport = window as unknown as Window & {
@@ -255,7 +263,7 @@ export default (target: Element, options: Options): CustomScrollAction[] => {
255263 let cursor : Element | null = target
256264 while ( isElement ( cursor ) && checkBoundary ( cursor ) ) {
257265 // Move cursor to parent
258- cursor = cursor . parentElement
266+ cursor = getParentElement ( cursor )
259267
260268 // Stop when we reach the viewport
261269 if ( cursor === scrollingElement ) {
You can’t perform that action at this time.
0 commit comments