10 Commits

Author SHA1 Message Date
Kristiyan Kostadinov
1aebf165db fix(common): viewport scroller not finding elements inside the shadow DOM ()
The `ViewportScroller` figures out which element to scroll into view using `document.getElementById`. The problem is that it won't find elements inside the shadow DOM.

These changes add some extra logic that goes through all the shadow roots to look for the element.

Fixes .

PR Close 
2021-04-15 12:47:05 -07:00
Andrew Scott
112dff81b0 test(router): update scroller tests to use real objects ()
The current tests in the router scroller are
[change-detector tests](https://testing.googleblog.com/2015/01/testing-on-toilet-change-detector-tests.html)
and do not ensure the correct behavior of the scroller.
This commit updates the tests to assert actual scrolling behavior of the
browser.

PR Close 
2021-01-05 09:48:48 -08:00
Andrew Scott
a55f581add refactor(router): Remove unused property in BrowserViewportScroller ()
The `BrowserViewportScroller` injects but does not use the `ErrorHandler`.
This commit removes the `ErrorHandler` from the constructor.

PR Close 
2021-01-05 09:48:47 -08:00
WilliamKoza
b1d300dc26 fix(common): Prefer to use pageXOffset / pageYOffset instance of scrollX / scrollY ()
This fix ensures a better cross-browser compatibility.
This fix has been used for angular.io.

PR Close 
2020-11-19 12:22:03 -08:00
Andrew Scott
71079ce47e fix(common): Allow scrolling when browser supports scrollTo ()
This commit fixes a regression from "fix(common): ensure
scrollRestoration is writable ()" that caused scrolling to not
happen at all in browsers that do not support scroll restoration. The
issue was that `supportScrollRestoration` was updated to return `false`
if a browser did not have a writable `scrollRestoration`. However, the
previous behavior was that the function would return `true` if
`window.scrollTo` was defined. Every scrolling function in the
`ViewportScroller` used `supportScrollRestoration` and, with the update
in bb88c9fa3daac80086efbda951d81c159e3840f4, no scrolling would be
performed if a browser did not have writable `scrollRestoration` but
_did_ have `window.scrollTo`.

Note, that this failure was detected in the saucelabs tests. IE does not
support scroll restoration so IE tests were failing.

PR Close 
2020-08-14 11:41:22 -07:00
Alessandro
354e66efad refactor(common): use getElementById in ViewportScroller.scrollToAnchor ()
This commit uses getElementById and getElementsByName when an anchor scroll happens,
to avoid escaping the anchor and wrapping the code in a try/catch block.

Related to 

PR Close 
2020-08-07 11:14:31 -07:00
marcvincenti
bb88c9fa3d fix(common): ensure scrollRestoration is writable ()
Some specialised browsers that do not support scroll restoration
(e.g. some web crawlers) do not allow `scrollRestoration` to be
writable.

We already sniff the browser to see if it has the `window.scrollTo`
method, so now we also check whether `window.history.scrollRestoration`
is writable too.

Fixes 

PR Close 
2020-08-05 16:13:15 -07:00
Joey Perrott
d1ea1f4c7f build: update license headers to reference Google LLC ()
Update the license headers throughout the repository to reference Google LLC
rather than Google Inc, for the required license headers.

PR Close 
2020-05-26 14:26:58 -04:00
Joey Perrott
698b0288be build: reformat repo to new clang@1.4.0 ()
PR Close 
2020-04-14 12:08:36 -07:00
Jason Aden
e8768acacc fix(common): escape query selector used when anchor scrolling ()
When an anchor scroll happens, we run document.querySelector. This value can be taken directly from the user. Therefore it's possible to throw an error on scrolling, which can cause the application to fail.

This PR escapes the selector before using it.

Related to 
[Internal discussion](https://groups.google.com/a/google.com/forum/#!topic/angular-users/d82GHfmRKLc)

PR Close 
2019-03-29 10:39:38 -07:00