1
0
forked from test/crm

fix: handle commented class declations

(cherry picked from commit 29894ffcca34ef60d1a9a27d9be19abd62d66a23)
This commit is contained in:
Shariq Ansari 2025-05-07 16:38:01 +05:30 committed by Mergify
parent 019662052a
commit 4dabcebee5

View File

@ -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],
) || []
)