From b832b9ab1b5bde116384c8b062b6655fb2f28060 Mon Sep 17 00:00:00 2001 From: Thomas Fritsch <tf@kumquats.fr> Date: Fri, 7 Feb 2020 17:07:48 +0100 Subject: [PATCH] B.3.3. gestion autoclosing tag --- js/main.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/js/main.js b/js/main.js index 4616e18..e611a30 100644 --- a/js/main.js +++ b/js/main.js @@ -32,11 +32,16 @@ class Component { } render() { - return `<${this.tag}> - ${this.children ? this.children : ''} - </${this.tag}>`; + return `<${this.tag} ${ + this.children ? + `>${this.children}</${this.tag}>` : + ' />' + }`; } } const title = new Component( 'h1', 'La carte' ); -document.querySelector('.pageTitle').innerHTML = title.render(); \ No newline at end of file +document.querySelector('.pageTitle').innerHTML = title.render(); + +const img = new Component( 'img' ); +document.querySelector( '.pizzasContainer' ).innerHTML = img.render(); \ No newline at end of file -- GitLab