diff --git a/Test/parse.test.js b/Test/parse.test.js index c4b582a..f1764af 100644 --- a/Test/parse.test.js +++ b/Test/parse.test.js @@ -118,4 +118,35 @@ testParseClassFieldsWithInnerFunctionVariable() { } } +ParseConstructorWithFunctionsBelow() { + class Space extends Shadow { + $$form = Forms.observe(window.location.pathname, this) + + render = () => { + ForEach(this.form.children, (form) => { + switch(form.type) { + case "file": + File(form) + break + case "space": + ChildSpace(form) + break + case "link": + Link() + break + } + }) + } + + constructor() { + super() + } + + connectedCallback() { + } + } + + window.Registry.parseConstructor(Space) +} + }) \ No newline at end of file diff --git a/index.js b/index.js index 838a3c1..8808122 100644 --- a/index.js +++ b/index.js @@ -511,6 +511,7 @@ window.Registry = class Registry { let braceDepth = 0; let constructorFound = false let superCallFound = false; + let constructorEndFound = false; for (let i = 0; i < lines.length; i++) { let line = lines[i]; @@ -530,9 +531,10 @@ window.Registry = class Registry { modifiedLines.push(` window.Registry.construct(this, window.Registry.currentStateVariables, ...window.Registry.currentParams);`); } - if (constructorFound && braceDepth === 1 && superCallFound) { + if (constructorFound && braceDepth === 1 && superCallFound && !constructorEndFound) { modifiedLines.splice(modifiedLines.length - 1, 0, ' Object.preventExtensions(this);'); modifiedLines.splice(modifiedLines.length - 1, 0, ' window.Registry.testInitialized(this);'); + constructorEndFound = true } }