Skip to content

Commit a5b9ae4

Browse files
authored
Merge pull request #315 from tindzk/getelementsby
Return HTMLCollection in getElementsBy*()
2 parents a75727d + 7d2891c commit a5b9ae4

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

+25-16
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.
@@ -2848,7 +2857,7 @@ abstract class Document
28482857
*
28492858
* MDN
28502859
*/
2851-
def getElementsByTagName(tagname: String): NodeList = js.native
2860+
def getElementsByTagName(name: String): HTMLCollection = js.native
28522861

28532862
/**
28542863
* Returns a list of elements with the given tag name belonging to the given namespace.
@@ -2857,7 +2866,7 @@ abstract class Document
28572866
* MDN
28582867
*/
28592868
def getElementsByTagNameNS(namespaceURI: String,
2860-
localName: String): NodeList = js.native
2869+
localName: String): HTMLCollection = js.native
28612870

28622871
/**
28632872
* Returns a set of elements which have all the given class names. When called on the
@@ -2867,7 +2876,7 @@ abstract class Document
28672876
*
28682877
* MDN
28692878
*/
2870-
def getElementsByClassName(classNames: String): NodeList = js.native
2879+
def getElementsByClassName(classNames: String): HTMLCollection = js.native
28712880

28722881
/**
28732882
* Returns the element from the document whose elementFromPoint method is being

0 commit comments

Comments
 (0)