Skip to content

Commit c4abaa7

Browse files
committed
refactor: Simplify body class utility
1 parent 15bdb72 commit c4abaa7

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/utils/editor-environment.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import './editor-styles';
2020
export async function setUpEditorEnvironment() {
2121
try {
2222
setUpGlobalErrorHandlers();
23-
setBodyClasses( window );
23+
setBodyClasses();
2424
await awaitGBKitGlobal();
2525
await configureLocale();
2626
await initializeWordPressGlobals();
@@ -34,28 +34,24 @@ export async function setUpEditorEnvironment() {
3434
}
3535

3636
/**
37-
* Adds platform-specific CSS classes to document.body based on the provided
38-
* global-like object.
37+
* Adds conditional CSS classes to `document.body`.
3938
*
40-
* @param {Object} [global] - `window` or a mocked environment
4139
* @return {void}
4240
*/
43-
function setBodyClasses( global ) {
44-
if ( typeof global === 'undefined' ) {
41+
function setBodyClasses() {
42+
if ( typeof window === 'undefined' ) {
4543
return;
4644
}
4745

48-
const { document: { body } = {} } = global;
4946
const classNames = [];
5047

51-
// Detect platform and add class to body for platform-specific styling
5248
if ( Platform.isIOS ) {
5349
classNames.push( 'is-ios' );
5450
} else if ( Platform.isAndroid ) {
5551
classNames.push( 'is-android' );
5652
}
5753

58-
body.classList.add( ...classNames );
54+
window.document.body.classList.add( ...classNames );
5955
}
6056

6157
/**

0 commit comments

Comments
 (0)