From d14ec4abcb55c3e3734d2c5143ec044335a850a5 Mon Sep 17 00:00:00 2001
From: unknown <thomas.truffin.etu>
Date: Sun, 6 Feb 2022 22:04:09 +0100
Subject: [PATCH] exo 1 test fait
---
src/main.js | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/main.js b/src/main.js
index 55731cd..57a9391 100644
--- a/src/main.js
+++ b/src/main.js
@@ -36,7 +36,17 @@ class Component {
if (this.param.name !== undefined || this.param.value !== undefined)
param = `${this.param.name}="${this.param.value}"`;
if (this.children === null) return `<${this.tagName} ${param}/>`;
- return `<${this.tagName} ${param}> ${this.children} </${this.tagName}>`;
+ if (this.children instanceof Array)
+ return `<${this.tagName} ${param}> ${this.children.join('')} </${
+ this.tagName
+ }>`;
+ if (this.children instanceof String)
+ return `<${this.tagName} ${param}> ${this.children} </${this.tagName}>`;
+ if (this.children instanceof Component)
+ return `<${this.tagName} ${param}> ${this.children.render()} </${
+ this.tagName
+ }>`;
+ return '';
}
}
class img extends Component {
@@ -44,6 +54,5 @@ class img extends Component {
super('img', param);
}
}
-const title = new Component('img', { name: 'src', value: data[0].image });
-console.log(title.render());
+const title = new Component('h1', null, ['La', ' ', 'carte']);
document.querySelector('.pageTitle').innerHTML = title.render();
--
GitLab