PageSourceSearch

https://covenantbooksuk.org.uk/wp-content/themes/twentytwentyone/a…/js/editor-dark-mode-support.js?ver=1.0.0

js covenantbooksuk.org.uk collected 2026-10-06 15:06:56 UTC 1,242 bytes, 44 lines download raw bytes

1/* global twentytwentyoneIsDarkMode, setTimeout */
2
3// Check the color scheme preference and inject the classes if necessary.
4if ( document.body.classList.contains( 'twentytwentyone-supports-dark-theme' ) ) {
5	twentytwentyoneDarkModeEditorInit();
6}
7
8/**
9 * Adds the dark mode class once the editor loads.
10 *
11 * Waits for the editor to load by periodically checking for an element, then adds the classes.
12 *
13 * @since Twenty Twenty-One 1.0
14 *
15 * @param {number} attempt Track the number of tries
16 * @return {void}
17 */
18function twentytwentyoneDarkModeEditorInit( attempt ) {
19	var container = document.querySelector( '.block-editor__typewriter' ),
20		maxAttempts = 8;
21
22	// Set the initial attempt if it's undefined.
23	attempt = attempt || 0;
24
25	if ( twentytwentyoneIsDarkMode() ) {
26		if ( null === container ) {
27			// Try again.
28			if ( attempt < maxAttempts ) {
29				setTimeout(
30					function() {
31						twentytwentyoneDarkModeEditorInit( attempt + 1 );
32					},
33					// Double the delay, give the server some time to breathe.
34					25 * Math.pow( 2, attempt )
35				);
36			}
37			return;
38		}
39
40		document.body.classList.add( 'is-dark-theme' );
41		document.documentElement.classList.add( 'is-dark-theme' );
42		container.classList.add( 'is-dark-theme' );
43	}
44}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.