@@ -286,28 +286,47 @@ TEST: addTests('isQuickPR', [
286286 'https://github.com/sindresorhus/refined-github/compare/test-branch?quick_pull=1' ,
287287] ) ;
288288
289- const prStateSelector = [
289+ const stateSelector = [
290290 '.State' ,
291291 '[class^="StateLabel"]' ,
292292] . join ( ',' ) ;
293293
294- export const isDraftPR = ( ) : boolean => $ ( prStateSelector ) ! . textContent ! . trim ( ) === 'Draft' ;
294+ export const isDraftPR = ( ) : boolean => isPR ( ) && $ ( stateSelector ) ? .textContent ! . trim ( ) === 'Draft' ;
295295export const isOpenPR = ( ) : boolean => {
296- const status = $ ( prStateSelector ) ! . textContent ! . trim ( ) ;
296+ if ( isPR ( ) ) {
297+ return false ;
298+ }
299+
300+ const status = $ ( stateSelector ) ?. textContent ! . trim ( ) ;
297301 return status === 'Open' || status === 'Draft' ;
298302} ;
299303
300304export const isMergedPR = ( ) : boolean => {
301- const status = $ ( prStateSelector ) ! . textContent ! . trim ( ) ;
305+ if ( isPR ( ) ) {
306+ return false ;
307+ }
308+
309+ const status = $ ( stateSelector ) ?. textContent ! . trim ( ) ;
302310 return status === 'Merged' ;
303311} ;
304312
305313export const isClosedPR = ( ) : boolean => {
306- const status = $ ( prStateSelector ) ! . textContent ! . trim ( ) ;
314+ if ( isPR ( ) ) {
315+ return false ;
316+ }
317+
318+ const status = $ ( stateSelector ) ?. textContent ! . trim ( ) ;
307319 return status === 'Closed' || status === 'Merged' ;
308320} ;
309321
310- export const isClosedIssue = ( ) : boolean => exists ( '#partial-discussion-header :is(.octicon-issue-closed, .octicon-skip)' ) ;
322+ export const isClosedIssue = ( ) : boolean => {
323+ if ( isIssue ( ) ) {
324+ return false ;
325+ }
326+
327+ const status = $ ( stateSelector ) ?. textContent ! . trim ( ) ;
328+ return status === 'Closed' ;
329+ } ;
311330
312331export const isReleases = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => getRepo ( url ) ?. path === 'releases' ;
313332TEST: addTests ( 'isReleases' , [
0 commit comments