Skip to content

Commit 7d2891c

Browse files
committed
Return HTMLCollection in getElementsBy*()
See also: - https://dom.spec.whatwg.org/#document - https://dom.spec.whatwg.org/#element
1 parent 28503dc commit 7d2891c

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

src/main/scala/org/scalajs/dom/raw/lib.scala

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -804,15 +804,35 @@ abstract class Element
804804
*/
805805
def getAttribute(name: String): String = js.native
806806

807+
/**
808+
* Returns a list of elements with the given tag name. The subtree underneath the
809+
* specified element is searched, excluding the element itself. The returned list is
810+
* live, meaning that it updates itself with the DOM tree automatically.
811+
* Consequently, there is no need to call several times
812+
* element.getElementsByTagName with the same element and arguments.
813+
*
814+
* MDN
815+
*/
816+
def getElementsByTagName(name: String): HTMLCollection = js.native
817+
807818
/**
808819
* Returns a list of elements with the given tag name belonging to the given namespace.
809820
*
810821
* MDN
811822
*/
812823
def getElementsByTagNameNS(namespaceURI: String,
813-
localName: String): NodeList = js.native
824+
localName: String): HTMLCollection = js.native
814825

815-
def getElementsByClassName(classNames: String): NodeList = js.native
826+
/**
827+
* Returns an array-like object of all child elements which have all of the
828+
* given class names. When called on the document object, the complete document
829+
* is searched, including the root node. You may also call getElementsByClassName()
830+
* on any element; it will return only elements which are descendants of the
831+
* specified root element with the given class names.
832+
*
833+
* MDN
834+
*/
835+
def getElementsByClassName(classNames: String): HTMLCollection = js.native
816836

817837
/**
818838
* hasAttributeNS returns a boolean value indicating whether the current element
@@ -886,17 +906,6 @@ abstract class Element
886906
*/
887907
def getAttributeNode(name: String): Attr = js.native
888908

889-
/**
890-
* Returns a list of elements with the given tag name. The subtree underneath the
891-
* specified element is searched, excluding the element itself. The returned list is
892-
* live, meaning that it updates itself with the DOM tree automatically.
893-
* Consequently, there is no need to call several times
894-
* element.getElementsByTagName with the same element and arguments.
895-
*
896-
* MDN
897-
*/
898-
def getElementsByTagName(name: String): NodeList = js.native
899-
900909
/**
901910
* Returns a collection of rectangles that indicate the bounding rectangles for each
902911
* box in a client.
@@ -2850,7 +2859,7 @@ abstract class Document
28502859
*
28512860
* MDN
28522861
*/
2853-
def getElementsByTagName(tagname: String): NodeList = js.native
2862+
def getElementsByTagName(name: String): HTMLCollection = js.native
28542863

28552864
/**
28562865
* Returns a list of elements with the given tag name belonging to the given namespace.
@@ -2859,7 +2868,7 @@ abstract class Document
28592868
* MDN
28602869
*/
28612870
def getElementsByTagNameNS(namespaceURI: String,
2862-
localName: String): NodeList = js.native
2871+
localName: String): HTMLCollection = js.native
28632872

28642873
/**
28652874
* Returns a set of elements which have all the given class names. When called on the
@@ -2869,7 +2878,7 @@ abstract class Document
28692878
*
28702879
* MDN
28712880
*/
2872-
def getElementsByClassName(classNames: String): NodeList = js.native
2881+
def getElementsByClassName(classNames: String): HTMLCollection = js.native
28732882

28742883
/**
28752884
* Returns the element from the document whose elementFromPoint method is being

0 commit comments

Comments
 (0)