Skip to content
Snippets Groups Projects
Commit d14ec4ab authored by unknown's avatar unknown
Browse files

exo 1 test fait

parent a1f74a8b
Branches
No related tags found
No related merge requests found
...@@ -36,7 +36,17 @@ class Component { ...@@ -36,7 +36,17 @@ class Component {
if (this.param.name !== undefined || this.param.value !== undefined) if (this.param.name !== undefined || this.param.value !== undefined)
param = `${this.param.name}="${this.param.value}"`; param = `${this.param.name}="${this.param.value}"`;
if (this.children === null) return `<${this.tagName} ${param}/>`; if (this.children === null) return `<${this.tagName} ${param}/>`;
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}>`; 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 { class img extends Component {
...@@ -44,6 +54,5 @@ class img extends Component { ...@@ -44,6 +54,5 @@ class img extends Component {
super('img', param); super('img', param);
} }
} }
const title = new Component('img', { name: 'src', value: data[0].image }); const title = new Component('h1', null, ['La', ' ', 'carte']);
console.log(title.render());
document.querySelector('.pageTitle').innerHTML = title.render(); document.querySelector('.pageTitle').innerHTML = title.render();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment