Diff options
| -rw-r--r-- | source/ui-diff.c | 2 | |
| -rw-r--r-- | source/ui-tree.c | 2 | |
| -rwxr-xr-x | tests/t0104-tree.sh | 6 | |
| -rwxr-xr-x | tests/t0107-diff.sh | 6 |
4 files changed, 14 insertions, 2 deletions
diff --git a/source/ui-diff.c b/source/ui-diff.c index 1549949..958d6e7 100644 --- a/source/ui-diff.c +++ b/source/ui-diff.c @@ -682,7 +682,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefi if (use_ssdiff) { html("<table class='ssdiff'>\n"); } else { - html("<table class='diff'>\n"); + html("<table class='diff' role='presentation'>\n"); html("<tr><td>"); } if (bodies_usable) { diff --git a/source/ui-tree.c b/source/ui-tree.c index f1b995a..eed5f25 100644 --- a/source/ui-tree.c +++ b/source/ui-tree.c @@ -81,7 +81,7 @@ static void print_linenumbers(const char *buf, size_t size) static void print_text_buffer(const char *filename, char *buf, size_t size) { - html("<table class='blob'>\n"); + html("<table class='blob' role='presentation'>\n"); if (ctx.cfg.enable_tree_linenumbers) { html("<tr><td class='linenumbers'><pre>"); diff --git a/tests/t0104-tree.sh b/tests/t0104-tree.sh index 35b1948..21fc74b 100755 --- a/tests/t0104-tree.sh +++ b/tests/t0104-tree.sh @@ -25,6 +25,12 @@ test_expect_success 'no line 2' ' ! grep "<a id=.n2. href=.#n2.>2</a>" tmp ' +# The table only sets the numbers beside the code, so a screen reader is told +# to read it as layout rather than as a table of data. +test_expect_success 'the file table is read as layout' ' + grep "<table class=.blob. role=.presentation.>" tmp +' + # The numbers and the code are two columns of text that a browser keeps in # step only while both are set in one font. Only a browser shows the drift, # so this checks the rule that prevents it. diff --git a/tests/t0107-diff.sh b/tests/t0107-diff.sh index d03ecd2..3c1f09c 100755 --- a/tests/t0107-diff.sh +++ b/tests/t0107-diff.sh @@ -22,6 +22,12 @@ test_expect_success 'find added line' ' grep "<div class=.add.>+5</div>" tmp ' +# The unified diff sits in a single cell, which holds the files together +# rather than tabulating them, so a screen reader is told it is layout. +test_expect_success 'the unified diff table is read as layout' ' + grep "<table class=.diff. role=.presentation.>" tmp +' + # A revision that names no commit is quoted the way the request wrote it, as # the commit and patch pages quote it, on either side of the diff. test_expect_success 'a tree on either side is named as the request gave it' ' |
