diff --git a/Test/parse.test.js b/Test/parse.test.js index 8e104fa..8621b3f 100644 --- a/Test/parse.test.js +++ b/Test/parse.test.js @@ -148,52 +148,4 @@ window.testSuites.push( class testParse { window.Registry.parseConstructor(Space) } - - // CopyTo() { - // let str = "render=()=>{VStack(()=>{" - // let ret = str.copyTo("{") - - // if(ret !== "render=()=>") return "Copy 1 failed!" - // } - - ParseRender() { - class Sidebar extends Shadow { - $$windowState = windowState - $$form = Forms.observe(window.location.pathname) - $sidebarPos = -200 - - render = () => { - VStack(() => { - ForEach(this.form.children, (form) => { - switch(form.constructor.name) { - case "File": - SidebarFile(form) - break - case "Space": - SidebarSpace(form) - break - } - }) - }) - .background("black") - .positionType("absolute") - .x(this.windowState.sidebarOut ? 0 : -200) - .y(0) - .width(200, "px") - .height(100, "vh") - } - } - - let result = new Registry.parseRender(Sidebar).parse() - console.log(result) - - let expectedOutput = "[[VStack.ForEach, form.children], [VStack.x, windowState.sidebarOut]]" - - if(JSON.stringify(result) !== JSON.stringify(expectedOutput)) { - return "Result does not match expected array!" - } - } - - // disallow addEventListener inside of render - }) \ No newline at end of file diff --git a/Test/parserender.test.js b/Test/parserender.test.js new file mode 100644 index 0000000..80f52c8 --- /dev/null +++ b/Test/parserender.test.js @@ -0,0 +1,54 @@ +window.testSuites.push( + + +class ParseRender { + // CopyTo() { + // let str = "render=()=>{VStack(()=>{" + // let ret = str.copyTo("{") + + // if(ret !== "render=()=>") return "Copy 1 failed!" + // } + + ParseRender() { + class Sidebar extends Shadow { + $$windowState = windowState + $$form = Forms.observe(window.location.pathname) + $sidebarPos = -200 + + render = () => { + VStack(() => { + ForEach(this.form.children, (form) => { + switch(form.constructor.name) { + case "File": + SidebarFile(form) + break + case "Space": + SidebarSpace(form) + break + } + }) + }) + .background("black") + .positionType("absolute") + .x(this.windowState.sidebarOut ? 0 : -200) + .y(0) + .width(200, "px") + .height(100, "vh") + } + } + + let result = new Registry.parseRender(Sidebar).parse() + console.log(result) + + let expectedOutput = "[[VStack.ForEach, form.children], [VStack.x, windowState.sidebarOut]]" + + if(JSON.stringify(result) !== JSON.stringify(expectedOutput)) { + return "Result does not match expected array!" + } + } + + // only functions which return a view may be called + // no addEventListener usage +} + +) \ No newline at end of file diff --git a/Test/test.js b/Test/test.js index b847081..15b1048 100644 --- a/Test/test.js +++ b/Test/test.js @@ -5,6 +5,7 @@ await import ("./parse.test.js") await import ("./init.test.js") await import ("./render.test.js") await import ("./observedobject.test.js") +await import ("./parserender.test.js") window.randomName = function randomName(prefix) { const sanitizedPrefix = prefix.toLowerCase().replace(/[^a-z0-9]/g, ''); diff --git a/app.js b/app.js new file mode 100644 index 0000000..2735a2e --- /dev/null +++ b/app.js @@ -0,0 +1,13 @@ +/* +Captured Sun +*/ + +"use strict"; + +class Home extends Page { + render = () => { + ("hello world") + } +} + +export default Home \ No newline at end of file diff --git a/index.html b/index.html index f1ea129..be47f22 100644 --- a/index.html +++ b/index.html @@ -5,18 +5,13 @@ - + diff --git a/index.js b/index.js index a422e92..0483fc1 100644 --- a/index.js +++ b/index.js @@ -675,6 +675,10 @@ function extendHTMLElementWithStyleSetters() { extendHTMLElementWithStyleSetters(); HTMLElement.prototype.padding = function(direction, value) { + if(!value) { + this.style.padding = direction; + } + const directionName = `padding${direction.charAt(0).toUpperCase()}${direction.slice(1)}`; if (typeof value === 'number') { this.style[directionName] = `${value}px`;