marko
Version:
UI Components + streaming, async, high performance, HTML templating for Node.js and the browser.
72 lines (53 loc) • 1.29 kB
JavaScript
"use strict";
class ServerComponent {
constructor(id, input, out, typeName, customEvents, scope) {
this.id = id;
this.V_ = customEvents;
this.W_ = scope;
this.typeName = typeName;
this.X_ = undefined; // Used to keep track of bubbling DOM events for components rendered on the server
this.Z_ = 0;
this.onCreate(input, out);
this.___ = this.onInput(input, out) || input;
if (this.O_ === undefined) {
this.O_ = this.___;
}
this.onRender(out);
}
set input(newInput) {
this.O_ = newInput;
}
get input() {
return this.O_;
}
set state(newState) {
this.z_ = newState;
}
get state() {
return this.z_;
}
get aB_() {
return this.z_;
}
elId(nestedId) {
var id = this.id;
if (nestedId == null) {
return id;
} else {
if (typeof nestedId !== "string") {
// eslint-disable-next-line no-constant-condition
nestedId = String(nestedId);
}
if (nestedId.indexOf("#") === 0) {
id = "#" + id;
nestedId = nestedId.substring(1);
}
return id + "-" + nestedId;
}
}
onCreate() {}
onInput() {}
onRender() {}
}
ServerComponent.prototype.getElId = ServerComponent.prototype.elId;
module.exports = ServerComponent;