Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-inclu.../js/dist
File: interactivity-router.js
import * as __WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__ from "@wordpress/interactivity";
[0] Fix | Delete
/******/ // The require scope
[1] Fix | Delete
/******/ var __webpack_require__ = {};
[2] Fix | Delete
/******/
[3] Fix | Delete
/************************************************************************/
[4] Fix | Delete
/******/ /* webpack/runtime/define property getters */
[5] Fix | Delete
/******/ (() => {
[6] Fix | Delete
/******/ // define getter functions for harmony exports
[7] Fix | Delete
/******/ __webpack_require__.d = (exports, definition) => {
[8] Fix | Delete
/******/ for(var key in definition) {
[9] Fix | Delete
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
[10] Fix | Delete
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
[11] Fix | Delete
/******/ }
[12] Fix | Delete
/******/ }
[13] Fix | Delete
/******/ };
[14] Fix | Delete
/******/ })();
[15] Fix | Delete
/******/
[16] Fix | Delete
/******/ /* webpack/runtime/hasOwnProperty shorthand */
[17] Fix | Delete
/******/ (() => {
[18] Fix | Delete
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
[19] Fix | Delete
/******/ })();
[20] Fix | Delete
/******/
[21] Fix | Delete
/************************************************************************/
[22] Fix | Delete
var __webpack_exports__ = {};
[23] Fix | Delete
[24] Fix | Delete
// EXPORTS
[25] Fix | Delete
__webpack_require__.d(__webpack_exports__, {
[26] Fix | Delete
o: () => (/* binding */ actions),
[27] Fix | Delete
w: () => (/* binding */ state)
[28] Fix | Delete
});
[29] Fix | Delete
[30] Fix | Delete
;// CONCATENATED MODULE: external "@wordpress/interactivity"
[31] Fix | Delete
var x = (y) => {
[32] Fix | Delete
var x = {}; __webpack_require__.d(x, y); return x
[33] Fix | Delete
}
[34] Fix | Delete
var y = (x) => (() => (x))
[35] Fix | Delete
const interactivity_namespaceObject = x({ ["getConfig"]: () => (__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.getConfig), ["privateApis"]: () => (__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.privateApis), ["store"]: () => (__WEBPACK_EXTERNAL_MODULE__wordpress_interactivity_8e89b257__.store) });
[36] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/interactivity-router/build-module/index.js
[37] Fix | Delete
var _getConfig$navigation;
[38] Fix | Delete
/**
[39] Fix | Delete
* WordPress dependencies
[40] Fix | Delete
*/
[41] Fix | Delete
[42] Fix | Delete
[43] Fix | Delete
/**
[44] Fix | Delete
* Internal dependencies
[45] Fix | Delete
*/
[46] Fix | Delete
[47] Fix | Delete
const {
[48] Fix | Delete
directivePrefix,
[49] Fix | Delete
getRegionRootFragment,
[50] Fix | Delete
initialVdom,
[51] Fix | Delete
toVdom,
[52] Fix | Delete
render,
[53] Fix | Delete
parseInitialData,
[54] Fix | Delete
populateInitialData,
[55] Fix | Delete
batch
[56] Fix | Delete
} = (0,interactivity_namespaceObject.privateApis)('I acknowledge that using private APIs means my theme or plugin will inevitably break in the next version of WordPress.');
[57] Fix | Delete
// Check if the navigation mode is full page or region based.
[58] Fix | Delete
const navigationMode = (_getConfig$navigation = (0,interactivity_namespaceObject.getConfig)('core/router').navigationMode) !== null && _getConfig$navigation !== void 0 ? _getConfig$navigation : 'regionBased';
[59] Fix | Delete
[60] Fix | Delete
// The cache of visited and prefetched pages, stylesheets and scripts.
[61] Fix | Delete
const pages = new Map();
[62] Fix | Delete
const headElements = new Map();
[63] Fix | Delete
[64] Fix | Delete
// Helper to remove domain and hash from the URL. We are only interesting in
[65] Fix | Delete
// caching the path and the query.
[66] Fix | Delete
const getPagePath = url => {
[67] Fix | Delete
const u = new URL(url, window.location.href);
[68] Fix | Delete
return u.pathname + u.search;
[69] Fix | Delete
};
[70] Fix | Delete
[71] Fix | Delete
// Fetch a new page and convert it to a static virtual DOM.
[72] Fix | Delete
const fetchPage = async (url, {
[73] Fix | Delete
html
[74] Fix | Delete
}) => {
[75] Fix | Delete
try {
[76] Fix | Delete
if (!html) {
[77] Fix | Delete
const res = await window.fetch(url);
[78] Fix | Delete
if (res.status !== 200) {
[79] Fix | Delete
return false;
[80] Fix | Delete
}
[81] Fix | Delete
html = await res.text();
[82] Fix | Delete
}
[83] Fix | Delete
const dom = new window.DOMParser().parseFromString(html, 'text/html');
[84] Fix | Delete
return regionsToVdom(dom);
[85] Fix | Delete
} catch (e) {
[86] Fix | Delete
return false;
[87] Fix | Delete
}
[88] Fix | Delete
};
[89] Fix | Delete
[90] Fix | Delete
// Return an object with VDOM trees of those HTML regions marked with a
[91] Fix | Delete
// `router-region` directive.
[92] Fix | Delete
const regionsToVdom = async (dom, {
[93] Fix | Delete
vdom
[94] Fix | Delete
} = {}) => {
[95] Fix | Delete
const regions = {
[96] Fix | Delete
body: undefined
[97] Fix | Delete
};
[98] Fix | Delete
let head;
[99] Fix | Delete
if (false) {}
[100] Fix | Delete
if (navigationMode === 'regionBased') {
[101] Fix | Delete
const attrName = `data-${directivePrefix}-router-region`;
[102] Fix | Delete
dom.querySelectorAll(`[${attrName}]`).forEach(region => {
[103] Fix | Delete
const id = region.getAttribute(attrName);
[104] Fix | Delete
regions[id] = vdom?.has(region) ? vdom.get(region) : toVdom(region);
[105] Fix | Delete
});
[106] Fix | Delete
}
[107] Fix | Delete
const title = dom.querySelector('title')?.innerText;
[108] Fix | Delete
const initialData = parseInitialData(dom);
[109] Fix | Delete
return {
[110] Fix | Delete
regions,
[111] Fix | Delete
head,
[112] Fix | Delete
title,
[113] Fix | Delete
initialData
[114] Fix | Delete
};
[115] Fix | Delete
};
[116] Fix | Delete
[117] Fix | Delete
// Render all interactive regions contained in the given page.
[118] Fix | Delete
const renderRegions = page => {
[119] Fix | Delete
batch(() => {
[120] Fix | Delete
if (false) {}
[121] Fix | Delete
if (navigationMode === 'regionBased') {
[122] Fix | Delete
populateInitialData(page.initialData);
[123] Fix | Delete
const attrName = `data-${directivePrefix}-router-region`;
[124] Fix | Delete
document.querySelectorAll(`[${attrName}]`).forEach(region => {
[125] Fix | Delete
const id = region.getAttribute(attrName);
[126] Fix | Delete
const fragment = getRegionRootFragment(region);
[127] Fix | Delete
render(page.regions[id], fragment);
[128] Fix | Delete
});
[129] Fix | Delete
}
[130] Fix | Delete
if (page.title) {
[131] Fix | Delete
document.title = page.title;
[132] Fix | Delete
}
[133] Fix | Delete
});
[134] Fix | Delete
};
[135] Fix | Delete
[136] Fix | Delete
/**
[137] Fix | Delete
* Load the given page forcing a full page reload.
[138] Fix | Delete
*
[139] Fix | Delete
* The function returns a promise that won't resolve, useful to prevent any
[140] Fix | Delete
* potential feedback indicating that the navigation has finished while the new
[141] Fix | Delete
* page is being loaded.
[142] Fix | Delete
*
[143] Fix | Delete
* @param href The page href.
[144] Fix | Delete
* @return Promise that never resolves.
[145] Fix | Delete
*/
[146] Fix | Delete
const forcePageReload = href => {
[147] Fix | Delete
window.location.assign(href);
[148] Fix | Delete
return new Promise(() => {});
[149] Fix | Delete
};
[150] Fix | Delete
[151] Fix | Delete
// Listen to the back and forward buttons and restore the page if it's in the
[152] Fix | Delete
// cache.
[153] Fix | Delete
window.addEventListener('popstate', async () => {
[154] Fix | Delete
const pagePath = getPagePath(window.location.href); // Remove hash.
[155] Fix | Delete
const page = pages.has(pagePath) && (await pages.get(pagePath));
[156] Fix | Delete
if (page) {
[157] Fix | Delete
renderRegions(page);
[158] Fix | Delete
// Update the URL in the state.
[159] Fix | Delete
state.url = window.location.href;
[160] Fix | Delete
} else {
[161] Fix | Delete
window.location.reload();
[162] Fix | Delete
}
[163] Fix | Delete
});
[164] Fix | Delete
[165] Fix | Delete
// Initialize the router and cache the initial page using the initial vDOM.
[166] Fix | Delete
// Once this code is tested and more mature, the head should be updated for
[167] Fix | Delete
// region based navigation as well.
[168] Fix | Delete
if (false) {}
[169] Fix | Delete
pages.set(getPagePath(window.location.href), Promise.resolve(regionsToVdom(document, {
[170] Fix | Delete
vdom: initialVdom
[171] Fix | Delete
})));
[172] Fix | Delete
[173] Fix | Delete
// Check if the link is valid for client-side navigation.
[174] Fix | Delete
const isValidLink = ref => ref && ref instanceof window.HTMLAnchorElement && ref.href && (!ref.target || ref.target === '_self') && ref.origin === window.location.origin && !ref.pathname.startsWith('/wp-admin') && !ref.pathname.startsWith('/wp-login.php') && !ref.getAttribute('href').startsWith('#') && !new URL(ref.href).searchParams.has('_wpnonce');
[175] Fix | Delete
[176] Fix | Delete
// Check if the event is valid for client-side navigation.
[177] Fix | Delete
const isValidEvent = event => event && event.button === 0 &&
[178] Fix | Delete
// Left clicks only.
[179] Fix | Delete
!event.metaKey &&
[180] Fix | Delete
// Open in new tab (Mac).
[181] Fix | Delete
!event.ctrlKey &&
[182] Fix | Delete
// Open in new tab (Windows).
[183] Fix | Delete
!event.altKey &&
[184] Fix | Delete
// Download.
[185] Fix | Delete
!event.shiftKey && !event.defaultPrevented;
[186] Fix | Delete
[187] Fix | Delete
// Variable to store the current navigation.
[188] Fix | Delete
let navigatingTo = '';
[189] Fix | Delete
const {
[190] Fix | Delete
state,
[191] Fix | Delete
actions
[192] Fix | Delete
} = (0,interactivity_namespaceObject.store)('core/router', {
[193] Fix | Delete
state: {
[194] Fix | Delete
url: window.location.href,
[195] Fix | Delete
navigation: {
[196] Fix | Delete
hasStarted: false,
[197] Fix | Delete
hasFinished: false,
[198] Fix | Delete
texts: {
[199] Fix | Delete
loading: '',
[200] Fix | Delete
loaded: ''
[201] Fix | Delete
},
[202] Fix | Delete
message: ''
[203] Fix | Delete
}
[204] Fix | Delete
},
[205] Fix | Delete
actions: {
[206] Fix | Delete
/**
[207] Fix | Delete
* Navigates to the specified page.
[208] Fix | Delete
*
[209] Fix | Delete
* This function normalizes the passed href, fetchs the page HTML if
[210] Fix | Delete
* needed, and updates any interactive regions whose contents have
[211] Fix | Delete
* changed. It also creates a new entry in the browser session history.
[212] Fix | Delete
*
[213] Fix | Delete
* @param href The page href.
[214] Fix | Delete
* @param [options] Options object.
[215] Fix | Delete
* @param [options.force] If true, it forces re-fetching the URL.
[216] Fix | Delete
* @param [options.html] HTML string to be used instead of fetching the requested URL.
[217] Fix | Delete
* @param [options.replace] If true, it replaces the current entry in the browser session history.
[218] Fix | Delete
* @param [options.timeout] Time until the navigation is aborted, in milliseconds. Default is 10000.
[219] Fix | Delete
* @param [options.loadingAnimation] Whether an animation should be shown while navigating. Default to `true`.
[220] Fix | Delete
* @param [options.screenReaderAnnouncement] Whether a message for screen readers should be announced while navigating. Default to `true`.
[221] Fix | Delete
*
[222] Fix | Delete
* @return Promise that resolves once the navigation is completed or aborted.
[223] Fix | Delete
*/
[224] Fix | Delete
*navigate(href, options = {}) {
[225] Fix | Delete
const {
[226] Fix | Delete
clientNavigationDisabled
[227] Fix | Delete
} = (0,interactivity_namespaceObject.getConfig)();
[228] Fix | Delete
if (clientNavigationDisabled) {
[229] Fix | Delete
yield forcePageReload(href);
[230] Fix | Delete
}
[231] Fix | Delete
const pagePath = getPagePath(href);
[232] Fix | Delete
const {
[233] Fix | Delete
navigation
[234] Fix | Delete
} = state;
[235] Fix | Delete
const {
[236] Fix | Delete
loadingAnimation = true,
[237] Fix | Delete
screenReaderAnnouncement = true,
[238] Fix | Delete
timeout = 10000
[239] Fix | Delete
} = options;
[240] Fix | Delete
navigatingTo = href;
[241] Fix | Delete
actions.prefetch(pagePath, options);
[242] Fix | Delete
[243] Fix | Delete
// Create a promise that resolves when the specified timeout ends.
[244] Fix | Delete
// The timeout value is 10 seconds by default.
[245] Fix | Delete
const timeoutPromise = new Promise(resolve => setTimeout(resolve, timeout));
[246] Fix | Delete
[247] Fix | Delete
// Don't update the navigation status immediately, wait 400 ms.
[248] Fix | Delete
const loadingTimeout = setTimeout(() => {
[249] Fix | Delete
if (navigatingTo !== href) {
[250] Fix | Delete
return;
[251] Fix | Delete
}
[252] Fix | Delete
if (loadingAnimation) {
[253] Fix | Delete
navigation.hasStarted = true;
[254] Fix | Delete
navigation.hasFinished = false;
[255] Fix | Delete
}
[256] Fix | Delete
if (screenReaderAnnouncement) {
[257] Fix | Delete
navigation.message = navigation.texts.loading;
[258] Fix | Delete
}
[259] Fix | Delete
}, 400);
[260] Fix | Delete
const page = yield Promise.race([pages.get(pagePath), timeoutPromise]);
[261] Fix | Delete
[262] Fix | Delete
// Dismiss loading message if it hasn't been added yet.
[263] Fix | Delete
clearTimeout(loadingTimeout);
[264] Fix | Delete
[265] Fix | Delete
// Once the page is fetched, the destination URL could have changed
[266] Fix | Delete
// (e.g., by clicking another link in the meantime). If so, bail
[267] Fix | Delete
// out, and let the newer execution to update the HTML.
[268] Fix | Delete
if (navigatingTo !== href) {
[269] Fix | Delete
return;
[270] Fix | Delete
}
[271] Fix | Delete
if (page && !page.initialData?.config?.['core/router']?.clientNavigationDisabled) {
[272] Fix | Delete
yield renderRegions(page);
[273] Fix | Delete
window.history[options.replace ? 'replaceState' : 'pushState']({}, '', href);
[274] Fix | Delete
[275] Fix | Delete
// Update the URL in the state.
[276] Fix | Delete
state.url = href;
[277] Fix | Delete
[278] Fix | Delete
// Update the navigation status once the the new page rendering
[279] Fix | Delete
// has been completed.
[280] Fix | Delete
if (loadingAnimation) {
[281] Fix | Delete
navigation.hasStarted = false;
[282] Fix | Delete
navigation.hasFinished = true;
[283] Fix | Delete
}
[284] Fix | Delete
if (screenReaderAnnouncement) {
[285] Fix | Delete
// Announce that the page has been loaded. If the message is the
[286] Fix | Delete
// same, we use a no-break space similar to the @wordpress/a11y
[287] Fix | Delete
// package: https://github.com/WordPress/gutenberg/blob/c395242b8e6ee20f8b06c199e4fc2920d7018af1/packages/a11y/src/filter-message.js#L20-L26
[288] Fix | Delete
navigation.message = navigation.texts.loaded + (navigation.message === navigation.texts.loaded ? '\u00A0' : '');
[289] Fix | Delete
}
[290] Fix | Delete
[291] Fix | Delete
// Scroll to the anchor if exits in the link.
[292] Fix | Delete
const {
[293] Fix | Delete
hash
[294] Fix | Delete
} = new URL(href, window.location.href);
[295] Fix | Delete
if (hash) {
[296] Fix | Delete
document.querySelector(hash)?.scrollIntoView();
[297] Fix | Delete
}
[298] Fix | Delete
} else {
[299] Fix | Delete
yield forcePageReload(href);
[300] Fix | Delete
}
[301] Fix | Delete
},
[302] Fix | Delete
/**
[303] Fix | Delete
* Prefetchs the page with the passed URL.
[304] Fix | Delete
*
[305] Fix | Delete
* The function normalizes the URL and stores internally the fetch
[306] Fix | Delete
* promise, to avoid triggering a second fetch for an ongoing request.
[307] Fix | Delete
*
[308] Fix | Delete
* @param url The page URL.
[309] Fix | Delete
* @param [options] Options object.
[310] Fix | Delete
* @param [options.force] Force fetching the URL again.
[311] Fix | Delete
* @param [options.html] HTML string to be used instead of fetching the requested URL.
[312] Fix | Delete
*/
[313] Fix | Delete
prefetch(url, options = {}) {
[314] Fix | Delete
const {
[315] Fix | Delete
clientNavigationDisabled
[316] Fix | Delete
} = (0,interactivity_namespaceObject.getConfig)();
[317] Fix | Delete
if (clientNavigationDisabled) {
[318] Fix | Delete
return;
[319] Fix | Delete
}
[320] Fix | Delete
const pagePath = getPagePath(url);
[321] Fix | Delete
if (options.force || !pages.has(pagePath)) {
[322] Fix | Delete
pages.set(pagePath, fetchPage(pagePath, {
[323] Fix | Delete
html: options.html
[324] Fix | Delete
}));
[325] Fix | Delete
}
[326] Fix | Delete
}
[327] Fix | Delete
}
[328] Fix | Delete
});
[329] Fix | Delete
[330] Fix | Delete
// Add click and prefetch to all links.
[331] Fix | Delete
if (false) {}
[332] Fix | Delete
[333] Fix | Delete
var __webpack_exports__actions = __webpack_exports__.o;
[334] Fix | Delete
var __webpack_exports__state = __webpack_exports__.w;
[335] Fix | Delete
export { __webpack_exports__actions as actions, __webpack_exports__state as state };
[336] Fix | Delete
[337] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function