From 811f246ad3b97de353737b5b284034f1c7f9df85 Mon Sep 17 00:00:00 2001 From: Charles Iliya Krempeaux Date: Wed, 15 Nov 2023 16:05:06 -0800 Subject: [PATCH] initial commits --- ziba.js | 20 +++++++++++++++++--- ziba_test.js | 7 +++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/ziba.js b/ziba.js index 9994f23..d53286d 100644 --- a/ziba.js +++ b/ziba.js @@ -20,26 +20,38 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ export function transform(rootElement) { + console.log("[ziba][transform] begin") + if (undefined === rootElement) { + console.log("[ziba][transform] root-elelemt is undefined") + console.log("[ziba][transform] end") return } transform_link(rootElement) + + console.log("[ziba][transform] end") } function transform_link(rootElement) { + console.log("[ziba][transform_link] begin") + if (undefined === rootElement) { - console.log("[ziba] root-elelemt is undefined") + console.log("[ziba][transform_link] root-elelemt is undefined") + console.log("[ziba][transform_link] end") return } const tagName = "ziba-link" const elements = rootElement.getElementsByTagName(tagName) if (!elements) { - console.log("[ziba] no elements") - console.log("[ziba] rootElement.innerHTML=", rootElement.innerHTML) + console.log("[ziba][transform_link] no elements") + console.log("[ziba][transform_link] rootElement.innerHTML=", rootElement.innerHTML) + console.log("[ziba][transform_link] end") return } + const length = elements.length + console.log("[ziba][transform_link] found", length, tagName) // Because we are doing a replaceWith() on the HTMLCollection, // we need to iterate through it backwards, because the HTMLCollection @@ -65,4 +77,6 @@ function transform_link(rootElement) { element.replaceWith(anchor) } + + console.log("[ziba][transform_link] end") } diff --git a/ziba_test.js b/ziba_test.js index 361c00b..fbc01f9 100644 --- a/ziba_test.js +++ b/ziba_test.js @@ -66,6 +66,13 @@ function testTransform() { html:'ONCE TWICE THRICE FOURCE', expected:'ONCE TWICE THRICE FOURCE', }, + + + + { + html:'', + expected:'', + }, ]