magic-akari / seamless-scroll-polyfill

Scroll Behavior polyfill
https://www.npmjs.com/package/seamless-scroll-polyfill
MIT License
159 stars 12 forks source link

elementScrollIntoView() breaks in an iframe #118

Closed dakur closed 3 years ago

dakur commented 3 years ago

Version: 1.2.4 / 2.0.0

If I use "Use method directly without patching" scenario:

import { elementScrollIntoView } from "seamless-scroll-polyfill";

elementScrollIntoView(someElement, {behavior: "smooth"});

and the element is in an iframe, it breaks on this line with TypeError: Argument 1 ('element') to Window.getComputedStyle must be an instance of Element getComputedStyle

I've tried to debug it and found out that in the for-loop, it resolves parents as follows:

There is probably some condition missing for iframe cases…

magic-akari commented 3 years ago

Hi, Could you try the 2.0.1 version ? feedback welcome.

dakur commented 3 years ago

@magic-akari Yes, that works. Thank you very much!

By the way, 2.0.x versions are not on npm, I had to install it with @next.

github-actions[bot] commented 3 years ago

:tada: This issue has been resolved in version 2.0.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] commented 3 years ago

:tada: This issue has been resolved in version 2.0.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] commented 3 years ago

:tada: This issue has been resolved in version 2.0.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: