From 7ac42eda52a2442a01f0044bdfbb929d3396b4bb Mon Sep 17 00:00:00 2001 From: Enix Date: Wed, 10 Apr 2019 09:59:44 +0800 Subject: [PATCH] fix: revert error condition --- src/utils/DOMHelper.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/utils/DOMHelper.ts b/src/utils/DOMHelper.ts index d8dcd72..b43b0e8 100644 --- a/src/utils/DOMHelper.ts +++ b/src/utils/DOMHelper.ts @@ -35,8 +35,8 @@ function $ any, O extends () => a otherwise?: O, ): E extends never ? O extends never - ? (Element | null) - : ReturnType | null + ? (Element | null) + : ReturnType | null : O extends never ? (ReturnType | null) : ReturnType | ReturnType { @@ -62,17 +62,18 @@ function getCurrentBranch() { const selectedBranchButtonSelector = '.repository-content .branch-select-menu summary' const branchButtonElement: HTMLElement = $(selectedBranchButtonSelector) if (branchButtonElement) { - const branchNameSpanElement = branchButtonElement.querySelector('span'); + const branchNameSpanElement = branchButtonElement.querySelector('span') if (branchNameSpanElement) { const partialBranchNameFromInnerText = branchNameSpanElement.innerText if (!partialBranchNameFromInnerText.includes('…')) return partialBranchNameFromInnerText } const defaultTitle = 'Switch branches or tags' - const title = (branchButtonElement).title.trim() + const title = branchButtonElement.title.trim() if (title !== defaultTitle) return title } - const findFileButtonSelector = '#js-repo-pjax-container .repository-content .file-navigation a[data-hotkey="t"]' + const findFileButtonSelector = + '#js-repo-pjax-container .repository-content .file-navigation a[data-hotkey="t"]' const urlFromFindFileButton: string | undefined = $( findFileButtonSelector, element => (element as HTMLAnchorElement).href, @@ -342,8 +343,10 @@ function attachCopySnippet() { }), () => { const readmeSelector = '.repository-content #readme' - $(readmeSelector, undefined, () => - raiseError(new Error('cannot find mount point for copy snippet button while readme exists')) + $(readmeSelector, () => + raiseError( + new Error('cannot find mount point for copy snippet button while readme exists'), + ), ) }, )