Themes: Move the skip link to outside the canvas in block themes

Fix Twenty Twenty-one having an erroneous margin above the Header template part
by moving the skip link outside of the wp-site-blocks canvas.

This is a backport of https://github.com/WordPress/gutenberg/pull/34986.

Props youknowriad.
Fixes #54491.




Built from https://develop.svn.wordpress.org/trunk@52243


git-svn-id: http://core.svn.wordpress.org/trunk@51835 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
noisysocks 2021-11-25 01:07:01 +00:00
parent dfdbbb4e62
commit 67e0125bc2
2 changed files with 5 additions and 5 deletions

View File

@ -165,7 +165,7 @@ function the_block_template_skip_link() {
<script> <script>
( function() { ( function() {
var skipLinkTarget = document.querySelector( 'main' ), var skipLinkTarget = document.querySelector( 'main' ),
parentEl, sibling,
skipLinkTargetID, skipLinkTargetID,
skipLink; skipLink;
@ -176,10 +176,10 @@ function the_block_template_skip_link() {
// Get the site wrapper. // Get the site wrapper.
// The skip-link will be injected in the beginning of it. // The skip-link will be injected in the beginning of it.
parentEl = document.querySelector( '.wp-site-blocks' ); sibling = document.querySelector( '.wp-site-blocks' );
// Early exit if the root element was not found. // Early exit if the root element was not found.
if ( ! parentEl ) { if ( ! sibling ) {
return; return;
} }
@ -197,7 +197,7 @@ function the_block_template_skip_link() {
skipLink.innerHTML = '<?php esc_html_e( 'Skip to content' ); ?>'; skipLink.innerHTML = '<?php esc_html_e( 'Skip to content' ); ?>';
// Inject the skip link. // Inject the skip link.
parentEl.insertAdjacentElement( 'afterbegin', skipLink ); sibling.parentElement.insertBefore( skipLink, sibling );
}() ); }() );
</script> </script>
<?php <?php

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.9-alpha-52242'; $wp_version = '5.9-alpha-52243';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.