Make parent optional

This commit is contained in:
Jordan Eldredge 2019-10-14 08:52:46 -07:00
parent a8df0dd575
commit 8ed22cf414
2 changed files with 8 additions and 2 deletions

View file

@ -10,14 +10,14 @@ class MakiObject {
// type conversion differently. Having one type that holds both the pre and
// post type coerced values is too confusing.
attributes: { [key: string]: string | number | boolean | undefined };
parent: MakiObject;
parent: MakiObject | null;
_emitter: Emitter;
children: MakiObject[];
js_annotations: Object;
constructor(
node: XmlNode | null,
parent: MakiObject,
parent: MakiObject | null,
annotations: Object = {}
) {
if (node) {
@ -61,6 +61,9 @@ class MakiObject {
}
js_delete() {
if (this.parent == null) {
return;
}
this.parent.js_removeChild(this);
this.parent.js_trigger("js_update");
}

View file

@ -17,9 +17,12 @@ type Command =
class PopupMenu extends MakiObject {
_commands: Command[];
_guiParent: Group;
parent: MakiObject;
js_selectCommand: (id: number) => void;
constructor(node: XmlNode, parent: MakiObject, annotations: Object) {
super(node, parent, annotations);
this.parent = parent;
if (!(parent instanceof Group)) {
throw new Error(