fix: add PJAX container fallback logic

This commit is contained in:
EnixCoda 2021-12-25 12:20:56 +08:00
parent ed35566931
commit 73adbf0310

View file

@ -106,6 +106,11 @@ function resolvePageScope(defaultBranchName?: string) {
const pathSHAMap = new Map<string, string>()
// Try lookup PJAX containers, #js-repo-pjax-container could exist while #repo-content-pjax-container does not.
const pjaxContainerSelector = ['#repo-content-pjax-container', '#js-repo-pjax-container'].find(
selector => document.querySelector(selector),
)
export const GitHub: Platform = {
isEnterprise,
resolvePartialMetaData() {
@ -201,7 +206,7 @@ export const GitHub: Platform = {
delegatePJAXProps(options) {
if (!options?.node || options.node.type === 'blob')
return {
'data-pjax': '#repo-content-pjax-container, #js-repo-pjax-container',
'data-pjax': pjaxContainerSelector,
onClick() {
/* Overwriting default onClick */
},