From 9f6a59d8f9eb39615ed2cea5b1270cc37e62c5d8 Mon Sep 17 00:00:00 2001 From: Adam Wood <1017872+adamwoodnz@users.noreply.github.com> Date: Fri, 5 Jul 2024 11:28:29 +1200 Subject: [PATCH] 2024 Theme: Add guard around missing course outline data See https://github.com/WordPress/Learn/issues/2531 --- .../themes/pub/wporg-learn-2024/src/course-outline/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wp-content/themes/pub/wporg-learn-2024/src/course-outline/index.js b/wp-content/themes/pub/wporg-learn-2024/src/course-outline/index.js index d8e60617e..941ac06ee 100644 --- a/wp-content/themes/pub/wporg-learn-2024/src/course-outline/index.js +++ b/wp-content/themes/pub/wporg-learn-2024/src/course-outline/index.js @@ -4,6 +4,10 @@ import { Icon, drafts, lockOutline } from '@wordpress/icons'; import { renderToString } from '@wordpress/element'; document.addEventListener( 'DOMContentLoaded', () => { + if ( ! wporgCourseOutlineData ) { + return; + } + wporgCourseOutlineData[ 'in-progress' ]?.forEach( ( title ) => { const lessonLinks = document.querySelectorAll( '.wp-block-sensei-lms-course-outline-lesson' ); lessonLinks.forEach( ( link ) => {