Skip to content

Commit d3e867e

Browse files
committed
Add missing methods for select elements to Elements
1 parent a3cebc5 commit d3e867e

2 files changed

Lines changed: 37 additions & 37 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Add missing methods for select elements to `Elements`
13+
1014
## [2.0.1] - 2025-07-22
1115

1216
### Added

core/src/main/java/org/jboss/elemento/Elements.java

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
import org.gwtproject.event.shared.HandlerRegistration;
2727
import org.gwtproject.safehtml.shared.SafeHtml;
28-
2928
import elemental2.core.JsArray;
3029
import elemental2.dom.CSSStyleDeclaration;
3130
import elemental2.dom.DOMRect;
@@ -849,9 +848,9 @@ public static HTMLInputElementBuilder<HTMLInputElement> input(String type) {
849848
}
850849

851850
public static <E extends HTMLInputElement> HTMLInputElementBuilder<E> input(String type, Class<E> jType) {
852-
E el = createHtmlElement("input", jType);
853-
el.type = type;
854-
return new HTMLInputElementBuilder<>(el);
851+
E input = createHtmlElement("input", jType);
852+
input.type = type;
853+
return new HTMLInputElementBuilder<>(input);
855854
}
856855

857856
public static HTMLInputElementBuilder<HTMLInputElement> input(Element element) {
@@ -930,20 +929,17 @@ public static HTMLContainerBuilder<HTMLProgressElement> progress(Element element
930929
return wrapHtmlContainer(cast(element));
931930
}
932931

933-
public static HTMLContainerBuilder<HTMLSelectElement> select() {
934-
return htmlContainer("select", HTMLSelectElement.class);
932+
public static HTMLSelectElementBuilder<HTMLSelectElement> select() {
933+
HTMLSelectElement el = createHtmlElement("select", HTMLSelectElement.class);
934+
return new HTMLSelectElementBuilder<>(el);
935935
}
936936

937-
public static HTMLContainerBuilder<HTMLSelectElement> select(Element element) {
938-
return wrapHtmlContainer(cast(element));
937+
public static HTMLSelectElementBuilder<HTMLSelectElement> select(Element element) {
938+
return wrapSelectElement(cast(element));
939939
}
940940

941941
public static HTMLTextAreaElementBuilder<HTMLTextAreaElement> textarea() {
942-
return textarea(HTMLTextAreaElement.class);
943-
}
944-
945-
public static <E extends HTMLTextAreaElement> HTMLTextAreaElementBuilder<E> textarea(Class<E> jType) {
946-
E el = createHtmlElement("textarea", jType);
942+
HTMLTextAreaElement el = createHtmlElement("textarea", HTMLTextAreaElement.class);
947943
return new HTMLTextAreaElementBuilder<>(el);
948944
}
949945

@@ -952,7 +948,7 @@ public static HTMLTextAreaElementBuilder<HTMLTextAreaElement> textarea(Element e
952948
}
953949

954950

955-
// ------------------------------------------------------ factories & wrappers
951+
// ------------------------------------------------------ factories
956952

957953
/**
958954
* Returns a builder for the specified HTML element.
@@ -962,54 +958,54 @@ public static <E extends HTMLElement> HTMLElementBuilder<E> htmlElement(String e
962958
}
963959

964960
/**
965-
* Returns a builder for the existing HTML element.
961+
* Returns a builder for the specified HTML element.
966962
*/
967-
public static <E extends HTMLElement> HTMLElementBuilder<E> wrapHtmlElement(E element) {
968-
return new HTMLElementBuilder<>(element);
963+
public static <E extends HTMLElement> HTMLContainerBuilder<E> htmlContainer(String element, Class<E> type) {
964+
return new HTMLContainerBuilder<>(createHtmlElement(element, type));
969965
}
970966

971967
/**
972-
* Returns a builder for the specified input element.
968+
* Creates the specified HTML element.
973969
*/
974-
public static <E extends HTMLInputElement> HTMLInputElementBuilder<E> inputElement(String type, Class<E> jType) {
975-
E input = createHtmlElement("input", jType);
976-
input.type = type;
977-
return new HTMLInputElementBuilder<>(input);
970+
public static <E extends HTMLElement> E createHtmlElement(String element, Class<E> type) {
971+
return cast(document.createElement(element));
978972
}
979973

974+
// ------------------------------------------------------ wrappers
975+
980976
/**
981-
* Returns a builder for the existing input element.
977+
* Returns a builder for the existing HTML element.
982978
*/
983-
public static <E extends HTMLInputElement> HTMLInputElementBuilder<E> wrapInputElement(E element) {
984-
return new HTMLInputElementBuilder<>(element);
979+
public static <E extends HTMLElement> HTMLElementBuilder<E> wrapHtmlElement(E element) {
980+
return new HTMLElementBuilder<>(element);
985981
}
986982

987983
/**
988-
* Returns a builder for the existing text area element.
984+
* Returns a builder for the existing HTML element.
989985
*/
990-
public static <E extends HTMLTextAreaElement> HTMLTextAreaElementBuilder<E> wrapTextAreaElement(E element) {
991-
return new HTMLTextAreaElementBuilder<>(element);
986+
public static <E extends HTMLElement> HTMLContainerBuilder<E> wrapHtmlContainer(E element) {
987+
return new HTMLContainerBuilder<>(element);
992988
}
993989

994990
/**
995-
* Returns a builder for the specified HTML element.
991+
* Returns a builder for the existing input element.
996992
*/
997-
public static <E extends HTMLElement> HTMLContainerBuilder<E> htmlContainer(String element, Class<E> type) {
998-
return new HTMLContainerBuilder<>(createHtmlElement(element, type));
993+
public static <E extends HTMLInputElement> HTMLInputElementBuilder<E> wrapInputElement(E element) {
994+
return new HTMLInputElementBuilder<>(element);
999995
}
1000996

1001997
/**
1002-
* Returns a builder for the existing HTML element.
998+
* Returns a builder for the existing select element.
1003999
*/
1004-
public static <E extends HTMLElement> HTMLContainerBuilder<E> wrapHtmlContainer(E element) {
1005-
return new HTMLContainerBuilder<>(element);
1000+
public static <E extends HTMLSelectElement> HTMLSelectElementBuilder<E> wrapSelectElement(E element) {
1001+
return new HTMLSelectElementBuilder<>(element);
10061002
}
10071003

10081004
/**
1009-
* Creates the specified HTML element.
1005+
* Returns a builder for the existing text area element.
10101006
*/
1011-
public static <E extends HTMLElement> E createHtmlElement(String element, Class<E> type) {
1012-
return cast(document.createElement(element));
1007+
public static <E extends HTMLTextAreaElement> HTMLTextAreaElementBuilder<E> wrapTextAreaElement(E element) {
1008+
return new HTMLTextAreaElementBuilder<>(element);
10131009
}
10141010

10151011
// ------------------------------------------------------ query methods

0 commit comments

Comments
 (0)