Skip to content
Snippets Groups Projects
Select Git revision
  • 7e3bc4290f5f6fe579174941c37b7c86bc3d9c84
  • master default protected
2 results

Component.js

Blame
  • Forked from an inaccessible project.
    user avatar
    Matthieu Vannin authored
    7e3bc429
    History
    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}/>`;
    			}
    		}
    	}
    }