From fae1797c1c10f0a9a97c458e7d3ca72724fbe447 Mon Sep 17 00:00:00 2001 From: metacryst Date: Mon, 29 Apr 2024 13:35:10 -0500 Subject: [PATCH] add zstack , allow render for svgs --- Test/parse.test.js | 2 ++ index.js | 59 +++++++++++++++++++++------------------------- 2 files changed, 29 insertions(+), 32 deletions(-) diff --git a/Test/parse.test.js b/Test/parse.test.js index 60803de..8e104fa 100644 --- a/Test/parse.test.js +++ b/Test/parse.test.js @@ -194,4 +194,6 @@ window.testSuites.push( class testParse { } } + // disallow addEventListener inside of render + }) \ No newline at end of file diff --git a/index.js b/index.js index 3de71ef..a422e92 100644 --- a/index.js +++ b/index.js @@ -120,23 +120,6 @@ window.quillStyles.update = function(tag, string) { sheet.insertRule(`${tag} { ${string} }`, sheet.cssRules.length); } -/* STRING TRANSLATORS */ - -window.html = function html(htmlString) { - let container = document.createElement('div'); - container.innerHTML = htmlString; - - if (container.children.length === 1) { - return container.children[0]; - } - - let fragment = document.createDocumentFragment(); - while (container.firstChild) { - fragment.appendChild(container.firstChild); - } - - return fragment; -}; /* COMPATIBILITY */ @@ -503,6 +486,24 @@ window.Registry = class Registry { /* DEFAULT WRAPPERS */ +window.html = function html(htmlString) { + let container = document.createElement('div'); + container.innerHTML = htmlString; + + if (container.children.length === 1) { + Registry.render(container.children[0]) + return container.children[0]; + } + + let fragment = document.createDocumentFragment(); + while (container.firstChild) { + fragment.appendChild(container.firstChild); + } + + Registry.render(fragment) + return fragment; +}; + window.a = function a({ href, name=href } = {}) { let link = document.createElement("a") link.setAttribute('href', href); @@ -577,6 +578,14 @@ window.HStack = function (cb = () => {}) { } } +window.ZStack = function (cb = () => {}) { + let nowRendering = window.rendering.last() + if(nowRendering.innerHTML === "") { + cb() + return nowRendering + } +} + /* SHAPES */ window.Circle = function(text = "") { @@ -604,20 +613,6 @@ window.Triangle = function() { return div } -window.Button = function(content = "") { - let div = document.createElement("div"); - div.innerHTML = content; - div.style.color = "white"; - div.style.textAlign = "center"; - div.style.display = "flex"; - div.style.alignItems = "center"; - div.style.justifyContent = "center"; - div.style.cursor = "pointer"; - - Registry.render(div); - return div; -} - /* PROTOTYPE FUNCTIONS */ Array.prototype.last = function() { @@ -648,7 +643,7 @@ HTMLElement.prototype.endingTag = function() { return ``; } -HTMLElement.prototype.render = function (...els) { +Element.prototype.render = function (...els) { if(els.length > 0) { this.innerHTML = "" els.forEach((el) => {