diff --git a/src/main.js b/src/main.js index 55731cd1c0fcd4fb0b7edfb423ae262ae76cba38..57a9391e4af78461cab15a075ae97481d030017a 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();