Make WordPress Core

Changeset 52243


Ignore:
Timestamp:
11/25/2021 01:05:30 AM (5 years ago)
Author:
noisysocks
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/theme-templates.php

    r52062 r52243  
    166166        ( function() {
    167167                var skipLinkTarget = document.querySelector( 'main' ),
    168                         parentEl,
     168                        sibling,
    169169                        skipLinkTargetID,
    170170                        skipLink;
     
    177177                // Get the site wrapper.
    178178                // The skip-link will be injected in the beginning of it.
    179                 parentEl = document.querySelector( '.wp-site-blocks' );
     179                sibling = document.querySelector( '.wp-site-blocks' );
    180180
    181181                // Early exit if the root element was not found.
    182                 if ( ! parentEl ) {
     182                if ( ! sibling ) {
    183183                        return;
    184184                }
     
    198198
    199199                // Inject the skip link.
    200                 parentEl.insertAdjacentElement( 'afterbegin', skipLink );
     200                sibling.parentElement.insertBefore( skipLink, sibling );
    201201        }() );
    202202        </script>
Note: See TracChangeset for help on using the changeset viewer.