From 2e50fbc532425fccd7ff0c8d85639899a148f150 Mon Sep 17 00:00:00 2001 From: Antoine Bluchet Date: Fri, 25 Oct 2024 09:36:06 +0200 Subject: [PATCH] handle empty code Co-authored-by: lwlinux <1053317536@qq.com> --- js/interactive-examples.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/interactive-examples.js b/js/interactive-examples.js index 41ae9bc40d..b80c114b48 100644 --- a/js/interactive-examples.js +++ b/js/interactive-examples.js @@ -48,10 +48,13 @@ class PHP { async function main() { let lastOutput = null; - document.querySelectorAll(".example").forEach((example) => { + document.querySelectorAll(".example .example-contents").forEach((example) => { const button = document.createElement("button"); button.setAttribute("type", "button"); const phpcode = example.querySelector(".phpcode"); + if (phpcode === null) { + return; + } const code = phpcode.querySelector("code"); code.setAttribute("contentEditable", true);