From 4dabcebee5c90b1bb71d14e1e816dde22296487f Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Wed, 7 May 2025 16:38:01 +0530 Subject: [PATCH] fix: handle commented class declations (cherry picked from commit 29894ffcca34ef60d1a9a27d9be19abd62d66a23) --- frontend/src/data/script.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend/src/data/script.js b/frontend/src/data/script.js index 94d37064..98563d92 100644 --- a/frontend/src/data/script.js +++ b/frontend/src/data/script.js @@ -167,8 +167,13 @@ export function getScript(doctype, view = 'Form') { // utility function to setup a form controller function getClassNames(script) { + const withoutComments = script + .replace(/\/\/.*$/gm, '') // Remove single-line comments + .replace(/\/\*[\s\S]*?\*\//g, '') // Remove multi-line comments + + // Match class declarations return ( - [...script.matchAll(/class\s+([A-Za-z0-9_]+)/g)].map( + [...withoutComments.matchAll(/class\s+([A-Za-z0-9_]+)/g)].map( (match) => match[1], ) || [] )