Skip to content

Add ParentNode interface #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion TS.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,13 @@ let EmitAddedInterface (ai: JsonItems.ItemsType.Root) =
| Some e -> Pt.printl "interface %s extends %s {" ai.Name.Value ai.Extends.Value
| None -> Pt.printl "interface %s {" ai.Name.Value

ai.Properties |> Array.iter (fun p -> Pt.printWithAddedIndent "%s: %s;" p.Name p.Type)
for p in ai.Properties do
let readOnlyModifier =
match p.Readonly with
| Some(true) -> "readonly "
| _ -> ""
Pt.printWithAddedIndent "%s%s: %s;" readOnlyModifier p.Name p.Type

ai.Methods |> Array.collect (fun m -> m.Signatures) |> Array.iter (Pt.printWithAddedIndent "%s;")
ai.Indexer |> Array.collect (fun i -> i.Signatures) |> Array.iter (Pt.printWithAddedIndent "%s;")
Pt.printl "}"
Expand Down
13 changes: 10 additions & 3 deletions baselines/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2289,7 +2289,7 @@ declare var DeviceRotationRate: {
new(): DeviceRotationRate;
}

interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEvent {
interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEvent, ParentNode {
/**
* Sets or gets the URL for the current document.
*/
Expand Down Expand Up @@ -3352,7 +3352,7 @@ declare var Document: {
new(): Document;
}

interface DocumentFragment extends Node, NodeSelector {
interface DocumentFragment extends Node, NodeSelector, ParentNode {
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
}

Expand Down Expand Up @@ -3421,7 +3421,7 @@ declare var EXT_texture_filter_anisotropic: {
readonly TEXTURE_MAX_ANISOTROPY_EXT: number;
}

interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelector, ChildNode {
interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelector, ChildNode, ParentNode {
readonly classList: DOMTokenList;
className: string;
readonly clientHeight: number;
Expand Down Expand Up @@ -14236,6 +14236,13 @@ interface JsonWebKey {
k?: string;
}

interface ParentNode {
readonly children: HTMLCollection;
readonly firstElementChild: Element;
readonly lastElementChild: Element;
readonly childElementCount: number;
}

declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;

interface ErrorEventHandler {
Expand Down
42 changes: 42 additions & 0 deletions inputfiles/addedTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -1133,5 +1133,47 @@
"interface": "KeyboardEventInit",
"name": "code?",
"type": "string"
},
{
"kind": "interface",
"name": "ParentNode",
"flavor": "DOM",
"properties": [
{
"name": "children",
"readonly": true,
"type": "HTMLCollection"
},
{
"name": "firstElementChild",
"readonly": true,
"type": "Element"
},
{
"name": "lastElementChild",
"readonly": true,
"type": "Element"
},
{
"name": "childElementCount",
"readonly": true,
"type": "number"
}
]
},
{
"kind": "extends",
"baseInterface": "ParentNode",
"interface": "Element"
},
{
"kind": "extends",
"baseInterface": "ParentNode",
"interface": "Document"
},
{
"kind": "extends",
"baseInterface": "ParentNode",
"interface": "DocumentFragment"
}
]
12 changes: 12 additions & 0 deletions inputfiles/sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -336,5 +336,17 @@
"kind": "extends",
"baseInterface": "ParentNode",
"interface": "Document"
},
{
"kind": "interface",
"name": "ParentNode",
"flavor": "DOM",
"properties": [
{
"name": "children",
"readonly": true,
"type": "HTMLCollection"
}
]
}
]