Select Git revision
Component.js
Forked from an inaccessible project.
Component.js 615 B
export default class Component {
tagName;
attribute;
children;
constructor(tagName, attribute, children) {
this.tagName = tagName;
this.attribute = attribute;
this.children = children;
}
renderAttribute() {
return `<${this.tagName} ${this.attribute.name}="${this.attribute.value}"/>`;
}
render() {
if (!(this.children == null || this.children == undefined)) {
return `<${this.tagName}>${this.children}</${this.tagName}>`;
} else {
if (!(this.attribute == null || this.attribute == undefined)) {
return this.renderAttribute();
} else {
return `<${this.tagName}/>`;
}
}
}
}