From 73adbf03101179c6bbb384611d55b28da08770cb Mon Sep 17 00:00:00 2001 From: EnixCoda Date: Sat, 25 Dec 2021 12:20:56 +0800 Subject: [PATCH] fix: add PJAX container fallback logic --- src/platforms/GitHub/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/platforms/GitHub/index.ts b/src/platforms/GitHub/index.ts index e6c9e00..136ee8c 100644 --- a/src/platforms/GitHub/index.ts +++ b/src/platforms/GitHub/index.ts @@ -106,6 +106,11 @@ function resolvePageScope(defaultBranchName?: string) { const pathSHAMap = new Map() +// 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 */ },