diff --git a/src/nodes/comment.ts b/src/nodes/comment.ts index 13925c2..8ba5ff8 100644 --- a/src/nodes/comment.ts +++ b/src/nodes/comment.ts @@ -6,7 +6,7 @@ export default class CommentNode extends Node { public clone(): CommentNode { return new CommentNode(this.rawText, null); } - public constructor(public rawText: string, parentNode: HTMLElement, range?: [number, number]) { + public constructor(public rawText: string, parentNode = null as HTMLElement | null, range?: [number, number]) { super(parentNode, range); } diff --git a/src/nodes/html.ts b/src/nodes/html.ts index 273f1cb..4c75e33 100644 --- a/src/nodes/html.ts +++ b/src/nodes/html.ts @@ -172,7 +172,7 @@ export default class HTMLElement extends Node { tagName: string, keyAttrs: KeyAttributes, public rawAttrs = '', - parentNode: HTMLElement | null, + parentNode = null as HTMLElement | null, range: [number, number], private voidTag = new VoidTag(), _parseOptions = {} as Partial diff --git a/src/nodes/text.ts b/src/nodes/text.ts index 3ed36b7..0eb9cd5 100644 --- a/src/nodes/text.ts +++ b/src/nodes/text.ts @@ -11,7 +11,7 @@ export default class TextNode extends Node { public clone(): TextNode { return new TextNode(this._rawText, null); } - public constructor(rawText: string, parentNode: HTMLElement, range?: [number, number]) { + public constructor(rawText: string, parentNode = null as HTMLElement | null, range?: [number, number]) { super(parentNode, range); this._rawText = rawText; }