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(
229
229
return 0
230
230
}
231
231
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
+
232
240
export default ( target : Element , options : Options ) : CustomScrollAction [ ] => {
233
241
//TODO: remove this hack when microbundle will support typescript >= 4.0
234
242
const windowWithViewport = window as unknown as Window & {
@@ -255,7 +263,7 @@ export default (target: Element, options: Options): CustomScrollAction[] => {
255
263
let cursor : Element | null = target
256
264
while ( isElement ( cursor ) && checkBoundary ( cursor ) ) {
257
265
// Move cursor to parent
258
- cursor = cursor . parentElement
266
+ cursor = getParentElement ( cursor )
259
267
260
268
// Stop when we reach the viewport
261
269
if ( cursor === scrollingElement ) {
You can’t perform that action at this time.
0 commit comments