Skip to content

Commit df56b47

Browse files
committed
fix(template): Use <div> instead of <main> to support Vue3 apps mounting
Vue3 does not replace the element while mounting but only renders within (replace inner HTML). So it would result in two stacked `<main>` elements which is invalid and an accessibility issue. Instead we just use a `<div>` element for mounting. For Vue2 apps this does not change anything as the whole element will be replaced with a new `<main>` element. For vanilla apps this will slightly decrease the accessibility as the main landmark is now missing, but this is not a hard accessibility issue as it would be for Vue3 apps having two main elements. Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 184e715 commit df56b47

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

core/templates/layout.guest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@
4747
</div>
4848
</header>
4949
<?php endif; ?>
50-
<main>
50+
<div>
5151
<h1 class="hidden-visually">
5252
<?php p($theme->getName()); ?>
5353
</h1>
5454
<?php print_unescaped($_['content']); ?>
55-
</main>
55+
</div>
5656
</div>
5757
</div>
5858
<?php

core/templates/layout.public.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
</div>
8181
</header>
8282

83-
<main id="content" class="app-<?php p($_['appid']) ?>">
83+
<div id="content" class="app-<?php p($_['appid']) ?>">
8484
<h1 class="hidden-visually">
8585
<?php
8686
if (isset($template) && $template->getHeaderTitle() !== '') {
@@ -90,7 +90,8 @@
9090
} ?>
9191
</h1>
9292
<?php print_unescaped($_['content']); ?>
93-
</main>
93+
</div>
94+
9495
<?php if (isset($template) && $template->getFooterVisible() && ($theme->getLongFooter() !== '' || $_['showSimpleSignUpLink'])) { ?>
9596
<footer>
9697
<p><?php print_unescaped($theme->getLongFooter()); ?></p>

core/templates/layout.user.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@
8181
</div>
8282
</header>
8383

84-
<main id="content" class="app-<?php p($_['appid']) ?>">
84+
<div id="content" class="app-<?php p($_['appid']) ?>">
8585
<h1 class="hidden-visually" id="page-heading-level-1">
8686
<?php p((!empty($_['application']) && !empty($_['pageTitle']) && $_['application'] != $_['pageTitle'])
8787
? $_['application'] . ': ' . $_['pageTitle']
8888
: (!empty($_['pageTitle']) ? $_['pageTitle'] : $theme->getName())
8989
); ?>
9090
</h1>
9191
<?php print_unescaped($_['content']); ?>
92-
</main>
92+
</div>
9393
<div id="profiler-toolbar"></div>
9494
</body>
9595
</html>

cypress/e2e/theming/a11y-color-contrast.cy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ describe('Accessibility of Nextcloud theming colors', () => {
122122
// Unset background image and thus use background-color for testing blur background (images do not work with axe-core)
123123
doc.body.style.backgroundImage = 'unset'
124124

125-
const root = doc.querySelector('main')
125+
const root = doc.querySelector('#content')
126126
if (root === null) {
127127
throw new Error('No test root found')
128128
}
@@ -137,7 +137,7 @@ describe('Accessibility of Nextcloud theming colors', () => {
137137
it(`color contrast of ${foreground} on ${background}`, () => {
138138
cy.document().then(doc => {
139139
const element = createTestCase(foreground, background)
140-
const root = doc.querySelector('main')
140+
const root = doc.querySelector('#content')
141141
// eslint-disable-next-line no-unused-expressions
142142
expect(root).not.to.be.undefined
143143
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion

0 commit comments

Comments
 (0)