@@ -28,40 +28,38 @@ function selectRange($linesEls, $selectionEndEl, $selectionStartEls) {
28
28
$linesEls . closest ( 'tr' ) . removeClass ( 'active' ) ;
29
29
30
30
// add hashchange to permalink
31
- const $ refInNewIssue = $ ( 'a.ref-in-new-issue' ) ;
32
- const $ copyPermalink = $ ( 'a.copy-line-permalink' ) ;
33
- const $ viewGitBlame = $ ( 'a.view_git_blame' ) ;
31
+ const refInNewIssue = document . querySelector ( 'a.ref-in-new-issue' ) ;
32
+ const copyPermalink = document . querySelector ( 'a.copy-line-permalink' ) ;
33
+ const viewGitBlame = document . querySelector ( 'a.view_git_blame' ) ;
34
34
35
35
const updateIssueHref = function ( anchor ) {
36
- if ( ! $refInNewIssue . length ) {
37
- return ;
38
- }
39
- const urlIssueNew = $refInNewIssue . attr ( 'data-url-issue-new' ) ;
40
- const urlParamBodyLink = $refInNewIssue . attr ( 'data-url-param-body-link' ) ;
36
+ if ( ! refInNewIssue ) return ;
37
+ const urlIssueNew = refInNewIssue . getAttribute ( 'data-url-issue-new' ) ;
38
+ const urlParamBodyLink = refInNewIssue . getAttribute ( 'data-url-param-body-link' ) ;
41
39
const issueContent = `${ toAbsoluteUrl ( urlParamBodyLink ) } #${ anchor } ` ; // the default content for issue body
42
- $ refInNewIssue. attr ( 'href' , `${ urlIssueNew } ?body=${ encodeURIComponent ( issueContent ) } ` ) ;
40
+ refInNewIssue . setAttribute ( 'href' , `${ urlIssueNew } ?body=${ encodeURIComponent ( issueContent ) } ` ) ;
43
41
} ;
44
42
45
43
const updateViewGitBlameFragment = function ( anchor ) {
46
- if ( ! $ viewGitBlame. length ) return ;
47
- let href = $ viewGitBlame. attr ( 'href' ) ;
44
+ if ( ! viewGitBlame ) return ;
45
+ let href = viewGitBlame . getAttribute ( 'href' ) ;
48
46
href = `${ href . replace ( / # L \d + $ | # L \d + - L \d + $ / , '' ) } ` ;
49
47
if ( anchor . length !== 0 ) {
50
48
href = `${ href } #${ anchor } ` ;
51
49
}
52
- $ viewGitBlame. attr ( 'href' , href ) ;
50
+ viewGitBlame . setAttribute ( 'href' , href ) ;
53
51
} ;
54
52
55
- const updateCopyPermalinkUrl = function ( anchor ) {
56
- if ( ! $ copyPermalink. length ) return ;
57
- let link = $ copyPermalink. attr ( 'data-url' ) ;
53
+ const updateCopyPermalinkUrl = function ( anchor ) {
54
+ if ( ! copyPermalink ) return ;
55
+ let link = copyPermalink . getAttribute ( 'data-url' ) ;
58
56
link = `${ link . replace ( / # L \d + $ | # L \d + - L \d + $ / , '' ) } #${ anchor } ` ;
59
- $ copyPermalink. attr ( 'data-url' , link ) ;
57
+ copyPermalink . setAttribute ( 'data-url' , link ) ;
60
58
} ;
61
59
62
60
if ( $selectionStartEls ) {
63
- let a = parseInt ( $selectionEndEl . attr ( 'rel' ) . slice ( 1 ) ) ;
64
- let b = parseInt ( $selectionStartEls . attr ( 'rel' ) . slice ( 1 ) ) ;
61
+ let a = parseInt ( $selectionEndEl [ 0 ] . getAttribute ( 'rel' ) . slice ( 1 ) ) ;
62
+ let b = parseInt ( $selectionStartEls [ 0 ] . getAttribute ( 'rel' ) . slice ( 1 ) ) ;
65
63
let c ;
66
64
if ( a !== b ) {
67
65
if ( a > b ) {
@@ -85,11 +83,11 @@ function selectRange($linesEls, $selectionEndEl, $selectionStartEls) {
85
83
}
86
84
}
87
85
$selectionEndEl . closest ( 'tr' ) . addClass ( 'active' ) ;
88
- changeHash ( `#${ $selectionEndEl . attr ( 'rel' ) } ` ) ;
86
+ changeHash ( `#${ $selectionEndEl [ 0 ] . getAttribute ( 'rel' ) } ` ) ;
89
87
90
- updateIssueHref ( $selectionEndEl . attr ( 'rel' ) ) ;
91
- updateViewGitBlameFragment ( $selectionEndEl . attr ( 'rel' ) ) ;
92
- updateCopyPermalinkUrl ( $selectionEndEl . attr ( 'rel' ) ) ;
88
+ updateIssueHref ( $selectionEndEl [ 0 ] . getAttribute ( 'rel' ) ) ;
89
+ updateViewGitBlameFragment ( $selectionEndEl [ 0 ] . getAttribute ( 'rel' ) ) ;
90
+ updateCopyPermalinkUrl ( $selectionEndEl [ 0 ] . getAttribute ( 'rel' ) ) ;
93
91
}
94
92
95
93
function showLineButton ( ) {
0 commit comments