File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed
Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change 7070 }
7171 } ) ;
7272
73- // If no scrollable elements, fall back to <body>,
74- // if it's in the jQuery collection
75- // (doing this because Safari sets scrollTop async,
76- // so can't set it to 1 and immediately get the value.)
7773 if ( ! scrollable . length ) {
7874 this . each ( function ( ) {
79- if ( this . nodeName === 'BODY' ) {
75+ // If no scrollable elements and <html> has scroll-behavior:smooth because
76+ // "When this property is specified on the root element, it applies to the viewport instead."
77+ // and "The scroll-behavior property of the … body element is *not* propagated to the viewport."
78+ // → https://drafts.csswg.org/cssom-view/#propdef-scroll-behavior
79+ if ( this === document . documentElement && $ ( this ) . css ( 'scrollBehavior' ) === 'smooth' ) {
80+ scrollable = [ this ] ;
81+ }
82+
83+ // If still no scrollable elements, fall back to <body>,
84+ // if it's in the jQuery collection
85+ // (doing this because Safari sets scrollTop async,
86+ // so can't set it to 1 and immediately get the value.)
87+ if ( ! scrollable . length && this . nodeName === 'BODY' ) {
8088 scrollable = [ this ] ;
8189 }
8290 } ) ;
You can’t perform that action at this time.
0 commit comments