mirror of
https://github.com/marko-js/marko.git
synced 2026-02-01 16:07:13 +00:00
fix: add stubs for some client side component apis
This commit is contained in:
parent
602eaad0a4
commit
4349f959f8
5
.changeset/young-books-sleep.md
Normal file
5
.changeset/young-books-sleep.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"marko": patch
|
||||
---
|
||||
|
||||
Add stubs for some client side component apis on the server.
|
||||
@ -66,8 +66,76 @@ class ServerComponent {
|
||||
onCreate() {}
|
||||
onInput() {}
|
||||
onRender() {}
|
||||
|
||||
isDestroyed() {
|
||||
return false;
|
||||
}
|
||||
|
||||
setState(name, value) {
|
||||
if (typeof name == "object") {
|
||||
if (this.___state) {
|
||||
Object.assign(this.___state, name);
|
||||
} else {
|
||||
this.___state = name;
|
||||
}
|
||||
} else {
|
||||
this.___state[name] = value;
|
||||
}
|
||||
}
|
||||
|
||||
setStateDirty(name, value) {
|
||||
if (typeof name == "object") {
|
||||
if (this.___state) {
|
||||
Object.assign(this.___state, name);
|
||||
} else {
|
||||
this.___state = name;
|
||||
}
|
||||
} else {
|
||||
this.___state[name] = value;
|
||||
}
|
||||
}
|
||||
|
||||
replaceState(newState) {
|
||||
this.___state = newState;
|
||||
}
|
||||
|
||||
subscribeTo() {
|
||||
notImplemented("subscribeTo");
|
||||
}
|
||||
|
||||
emit() {
|
||||
notImplemented("emit");
|
||||
}
|
||||
|
||||
getEl() {
|
||||
notImplemented("getEl");
|
||||
}
|
||||
|
||||
getEls() {
|
||||
notImplemented("getEls");
|
||||
}
|
||||
|
||||
getComponent() {
|
||||
notImplemented("getComponent");
|
||||
}
|
||||
|
||||
getComponents() {
|
||||
notImplemented("getComponents");
|
||||
}
|
||||
|
||||
forceUpdate() {
|
||||
notImplemented("forceUpdate");
|
||||
}
|
||||
|
||||
update() {
|
||||
notImplemented("update");
|
||||
}
|
||||
}
|
||||
|
||||
ServerComponent.prototype.getElId = ServerComponent.prototype.elId;
|
||||
|
||||
module.exports = ServerComponent;
|
||||
|
||||
function notImplemented(name) {
|
||||
throw new Error(name + " method not supported during SSR.");
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user