@@ -29,14 +29,14 @@ export interface IDom {
2929 * @param callback The function that receives a notification when an event of the specified type occurs.
3030 * @param capture If true, useCapture indicates that the user wishes to initiate capture.
3131 */
32- addEventListener ( eventName : string , callback : EventListener , capture : boolean ) : void ;
32+ addEventListener ( eventName : string , callback : EventListenerOrEventListenerObject , capture : boolean ) : void ;
3333 /**
3434 * Remove an event listener from the document.
3535 * @param eventName A string representing the event type to listen for.
3636 * @param callback The function to remove from the event.
3737 * @param capture Specifies whether the listener to be removed was registered as a capturing listener or not.
3838 */
39- removeEventListener ( eventName : string , callback : EventListener , capture : boolean ) : void ;
39+ removeEventListener ( eventName : string , callback : EventListenerOrEventListenerObject , capture : boolean ) : void ;
4040 /**
4141 * Adopts a node from an external document.
4242 * @param node The node to be adopted.
@@ -48,7 +48,8 @@ export interface IDom {
4848 * @param tagName A string that specifies the type of element to be created.
4949 * @return The created element.
5050 */
51- createElement ( tagName : string ) : Element ;
51+ createElement < T extends keyof HTMLElementTagNameMap > ( tagName : T ) : HTMLElementTagNameMap [ T ] ;
52+ createElement ( tagName : string ) : HTMLElement ;
5253 /**
5354 * Creates the specified HTML attribute
5455 * @param name A string that specifies the name of attribute to be created.
@@ -102,12 +103,20 @@ export interface IDom {
102103 * @return The found element.
103104 */
104105 getElementById ( id : string ) : Element ;
106+
107+ /**
108+ * Performs a query selector on the document and returns first matched element, depth first.
109+ * @param query The query to use in searching the document.
110+ * @return A list of all matched elements in the document.
111+ */
112+ querySelector < E extends Element = Element > ( selectors : string ) : E | null ;
113+
105114 /**
106115 * Performs a query selector on the document and returns all located matches.
107116 * @param query The query to use in searching the document.
108117 * @return A list of all matched elements in the document.
109118 */
110- querySelectorAll ( query : string ) : NodeList ;
119+ querySelectorAll < E extends Element = Element > ( selectors : string ) : NodeListOf < E > ;
111120 /**
112121 * Gets the element that is the next sibling of the provided element.
113122 * @param element The element whose next sibling is being located.
@@ -119,7 +128,7 @@ export interface IDom {
119128 * @param markup A string containing the markup to turn into a template. Note: This string must contain the template element as well.
120129 * @return The instance of HTMLTemplateElement that was created from the provided markup.
121130 */
122- createTemplateFromMarkup ( markup : string ) : Element ;
131+ createTemplateFromMarkup ( markup : string ) : HTMLTemplateElement ;
123132 /**
124133 * Appends a node to the parent, if provided, or the document.body otherwise.
125134 * @param newNode The node to append.
0 commit comments