Skip to content

Add nodeParent property to HTML, Document and DocumentFragment #66

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

Closed
wants to merge 12 commits into from
Closed
9 changes: 9 additions & 0 deletions baselines/dom.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2062,6 +2062,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven
*/
xmlVersion: string;
currentScript: HTMLScriptElement;
parentNode: parentNode;
adoptNode(source: Node): Node;
captureEvents(): void;
clear(): void;
Expand Down Expand Up @@ -2780,6 +2781,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec
id: string;
className: string;
innerHTML: string;
parentNode: parentNode;
getAttribute(name?: string): string;
getAttributeNS(namespaceURI: string, localName: string): string;
getAttributeNode(name: string): Attr;
Expand Down Expand Up @@ -12659,6 +12661,13 @@ declare var HTMLPictureElement: {
new(): HTMLPictureElement;
}

interface ParentNode {
children: HTMLCollection;
firstElementChild : Element;
lastElementChild : Element;
childElementCount: number;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about querySelector, and querySelctorAll?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HTML, Document and DocumentFragment interface already had been implimented NodeSelector interface. So, I think that no selector methods are required for ParentNode interface.


declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;

interface ErrorEventHandler {
Expand Down
35 changes: 35 additions & 0 deletions inputfiles/addedTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -400,5 +400,40 @@
"interface": "Element",
"name": "getElementsByTagName",
"signatures": ["getElementsByTagName(tagname: \"picture\"): NodeListOf<HTMLPictureElement>"]
},
{
"kind": "interface",
"name": "ParentNode",
"flavor": "DOM",
"properties": [
{
"name": "children",
"type": "HTMLCollection"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would add a "read-only" property here and make it "1". thought we do not support this in the script now, we should soon. this way we get the correct declaration later on. that also applies to the other properties.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I send New Issue?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did it. #67

},
{
"name": "firstElementChild ",
"type": "Element"
},
{
"name": "lastElementChild ",
"type": "Element"
},
{
"name": "childElementCount",
"type": "number"
}
]
},
{
"kind": "property",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i do not think this should be a property.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this interface, too?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be added to the extends list. i do not know how to do that though :) @zhengbli what is the right way to do this?

"interface": "Element",
"name": "parentNode",
"type": "parentNode"
},
{
"kind": "property",
"interface": "Document",
"name": "parentNode",
"type": "parentNode"
}
]