File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,9 @@ function onSelectMenuItemChanged(target) {
1919 target . setAttribute ( "aria-checked" , target . classList . contains ( "selected" ) ? "true" : "false" ) ;
2020}
2121
22+ // Used when we need to generate ids for ARIA.
23+ var idCounter = 0 ;
24+
2225function onNodeAdded ( target ) {
2326 var elem ;
2427 var res = document . location . href . match ( / g i t h u b .c o m \/ [ ^ \/ ] + \/ [ ^ \/ ] + \/ ( [ ^ \/ ] + ) ( \/ ? ) / ) ;
@@ -37,6 +40,20 @@ function onNodeAdded(target) {
3740 if ( elem = target . querySelector ( ".commit-title" ) )
3841 makeHeading ( elem , 2 ) ;
3942 }
43+ if ( [ "pull" , "commit" ] . indexOf ( res [ 1 ] ) >= 0 && res [ 2 ] == "/" ) {
44+ // Pull request or commit.
45+ // Lines of code which can be commented on.
46+ for ( elem of target . querySelectorAll ( ".add-line-comment" ) ) {
47+ // Put the comment button after the code instead of before.
48+ // elem is the Add line comment button.
49+ elem . setAttribute ( "id" , "axsg-alc" + idCounter ) ;
50+ // nextElementSibling is the actual code.
51+ elem . nextElementSibling . setAttribute ( "id" , "axsg-l" + idCounter ) ;
52+ // Reorder children using aria-owns.
53+ elem . parentNode . setAttribute ( "aria-owns" , "axsg-l" + idCounter + " axsg-alc" + idCounter ) ;
54+ ++ idCounter ;
55+ }
56+ }
4057
4158 // Site-wide stuff.
4259 // Checkable menu items; e.g. in watch and labels pop-ups.
You can’t perform that action at this time.
0 commit comments