Remove IntersectionObserver fallback

It is always provided by web2017-polyfills in core.

Also remove checks for requestAnimationFrame, which core now
assumes to exist.

Change-Id: Ia9dd0330b45c945cf4aca1ea0d4edadc7308e1fc
This commit is contained in:
Ed Sanders 2024-03-28 11:50:10 +00:00 committed by Jon Robson
parent f985f6d5ef
commit f63aaf26fe
4 changed files with 8 additions and 16 deletions

View file

@ -283,18 +283,12 @@ const setupTableOfContents = ( tocElement, bodyContent, initSectionObserverFn )
* @return {void}
*/
const main = () => {
const isIntersectionObserverSupported = 'IntersectionObserver' in window;
//
// Table of contents
//
const tocElement = document.getElementById( TOC_ID );
const bodyContent = document.getElementById( BODY_CONTENT_ID );
const isToCUpdatingAllowed = isIntersectionObserverSupported &&
window.requestAnimationFrame;
const tableOfContents = isToCUpdatingAllowed ?
setupTableOfContents( tocElement, bodyContent, initSectionObserver ) : null;
const tableOfContents = setupTableOfContents( tocElement, bodyContent, initSectionObserver );
//
// Sticky header
@ -311,8 +305,7 @@ const main = () => {
!!stickyIntersection &&
!!userLinksDropdown &&
allowedNamespace &&
allowedAction &&
isIntersectionObserverSupported;
allowedAction;
const { showStickyHeader } = initStickyHeaderABTests(
ABTestConfig,

View file

@ -11,7 +11,6 @@
function init() {
/** @type {boolean|undefined} */ let boundEvent;
const isRTL = document.documentElement.dir === 'rtl';
const rAF = window.requestAnimationFrame || setTimeout;
// Mark the tabs which can be collapsed under the more menu
// eslint-disable-next-line no-jquery/no-global-selector
@ -43,12 +42,12 @@ function init() {
if ( !boundEvent ) {
boundEvent = true;
$( window ).on( 'resize', mw.util.debounce( () => {
rAF( $.collapsibleTabs.handleResize );
requestAnimationFrame( $.collapsibleTabs.handleResize );
}, 10 ) );
}
// call our resize handler to setup the page
rAF( $.collapsibleTabs.handleResize );
requestAnimationFrame( $.collapsibleTabs.handleResize );
// When adding new links, a resize should be triggered (T139830).
mw.hook( 'util.addPortletLink' ).add( $.collapsibleTabs.handleResize );
return this;
@ -161,7 +160,7 @@ function init() {
$( this ).detach().prependTo( target ).data( 'collapsibleTabsSettings', outerData );
$( this ).attr( 'style', 'display: list-item;' );
collapsedContainerSettings.shifting = false;
rAF( $.collapsibleTabs.handleResize );
requestAnimationFrame( $.collapsibleTabs.handleResize );
} );
},
moveToExpanded: function ( $moving ) {
@ -188,7 +187,7 @@ function init() {
.data( 'collapsibleTabsSettings', data )
.animate( { width: expandedWidth + 'px' }, 'normal', function () {
$( this ).attr( 'style', 'display: block;' );
rAF( () => {
requestAnimationFrame( () => {
// Update the 'expandedWidth' in case someone was brazen enough to
// change the tab's contents after the page load *gasp* (T71729). This
// doesn't prevent a tab from collapsing back and forth once, but at

View file

@ -9,7 +9,6 @@ const INPUT_LOCATION_MOVED = 'header-moved',
// mediawiki.searchSuggest performance. Marks and Measures will only be
// recorded on the Vector skin and only if browser supported.
shouldTestSearchPerformance = !!( window.performance &&
!!window.requestAnimationFrame &&
!!performance.mark &&
!!performance.measure &&
!!performance.getEntriesByName &&

View file

@ -456,7 +456,8 @@
"mediawiki.experiments",
"skins.vector.icons.js",
"mediawiki.util",
"mediawiki.jqueryMsg"
"mediawiki.jqueryMsg",
"web2017-polyfills"
],
"messages": [
"vector-search-loader",