Sha256: 33dbc658b766a5eb50db8598648b240b8cd897bb4f8204631926536f5ab1342b

Contents?: true

Size: 564 Bytes

Versions: 7

Compression:

Stored size: 564 Bytes

Contents

import { htmlAttributes } from "../html/html-attributes";

export class Element {
  attributes: Record<string, any>;
  children: any[];
  type: string;

  constructor(type: string, attributes: Record<string, any> = {}) {
    this.children = [];
    this.type = type;
    this.attributes = attributes;
  }

  get renderWrapper(): string {
    return `<${this.type} ${htmlAttributes(this.attributes)}>${this.children.map(child => child.renderWrapper).join("")}</${this.type}>`;
  }

  add(child: any): Element {
    this.children.push(child);
    return this;
  }
}

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
clapton-0.0.24 lib/clapton/javascripts/src/components/element.ts
clapton-0.0.23 lib/clapton/javascripts/src/components/element.ts
clapton-0.0.22 lib/clapton/javascripts/src/components/element.ts
clapton-0.0.21 lib/clapton/javascripts/src/components/element.ts
clapton-0.0.20 lib/clapton/javascripts/src/components/element.ts
clapton-0.0.19 lib/clapton/javascripts/src/components/element.ts
clapton-0.0.18 lib/clapton/javascripts/src/components/element.ts