Skip to content

Commit

Permalink
docs(node): Add descriptions for Node classes
Browse files Browse the repository at this point in the history
  • Loading branch information
fb55 committed Apr 20, 2021
1 parent 8dc6824 commit 2475d2e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ export class Node {
}
}

/**
* A node that contains some data.
*/
export class DataNode extends Node {
/**
* @param type The type of the node
Expand All @@ -99,18 +102,27 @@ export class DataNode extends Node {
}
}

/**
* Text within the document.
*/
export class Text extends DataNode {
constructor(data: string) {
super(ElementType.Text, data);
}
}

/**
* Comments within the document.
*/
export class Comment extends DataNode {
constructor(data: string) {
super(ElementType.Comment, data);
}
}

/**
* Processing instructions, including doc types.
*/
export class ProcessingInstruction extends DataNode {
constructor(public name: string, data: string) {
super(ElementType.Directive, data);
Expand Down Expand Up @@ -161,6 +173,9 @@ export class NodeWithChildren extends Node {
}
}

/**
* The root node of the document.
*/
export class Document extends NodeWithChildren {
constructor(children: Node[]) {
super(ElementType.Root, children);
Expand All @@ -169,12 +184,19 @@ export class Document extends NodeWithChildren {
"x-mode"?: "no-quirks" | "quirks" | "limited-quirks";
}

/**
* The description of an individual attribute.
*/
interface Attribute {
name: string;
value: string;
namespace?: string;
prefix?: string;
}

/**
* An element within the DOM.
*/
export class Element extends NodeWithChildren {
/**
* @param name Name of the tag, eg. `div`, `span`.
Expand Down

0 comments on commit 2475d2e

Please sign in to comment.