Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/main/java/org/htmlunit/html/HtmlElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.htmlunit.html;

Check warning on line 15 in src/main/java/org/htmlunit/html/HtmlElement.java

View workflow job for this annotation

GitHub Actions / PMD

[PMD] reported by reviewdog 🐶 Too many static imports may lead to messy code Raw Output: {"level":"warning","locations":[{"physicalLocation":{"artifactLocation":{"uri":"file:///home/runner/work/htmlunit/htmlunit/src/main/java/org/htmlunit/html/HtmlElement.java"},"region":{"endColumn":3,"endLine":1645,"startColumn":1,"startLine":15}}}],"message":{"text":"Too many static imports may lead to messy code"},"ruleId":"TooManyStaticImports","ruleIndex":62}

import static org.htmlunit.BrowserVersionFeatures.HTMLELEMENT_REMOVE_ACTIVE_TRIGGERS_BLUR_EVENT;
import static org.htmlunit.BrowserVersionFeatures.KEYBOARD_EVENT_SPECIAL_KEYPRESS;
Expand Down Expand Up @@ -592,12 +592,8 @@
}

final WebClient webClient = page.getWebClient();
if (this instanceof HtmlTextInput
|| this instanceof HtmlTextArea
|| this instanceof HtmlTelInput
|| this instanceof HtmlNumberInput
|| this instanceof HtmlSearchInput
|| this instanceof HtmlPasswordInput) {
if (this instanceof HtmlSelectableTextInput
|| this instanceof HtmlTextArea) {
fireEvent(new KeyboardEvent(this, Event.TYPE_INPUT, c,
shiftPressed_ || isShiftNeeded, ctrlPressed_, altPressed_));
}
Expand Down
23 changes: 23 additions & 0 deletions src/test/java/org/htmlunit/html/HtmlElementTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1269,4 +1269,27 @@ public void acceptChar() throws Exception {
input.type(value);
assertEquals(value, input.getValue());
}

/**
* @throws Exception if an error occurs
*/
@Test
public void typeFiresInputEvent() throws Exception {
final String[] types = {"text", "tel", "number", "search", "password", "email", "url", "date", "time"};

for (final String type : types) {
final String html = DOCTYPE_HTML
+ "<html><body>\n"
+ "<input type='" + type + "' id='t'>\n"
+ "<script>\n"
+ " document.getElementById('t').addEventListener('input', function() {\n"
+ " document.title += 'input';\n"
+ " });\n"
+ "</script>\n"
+ "</body></html>";
final HtmlPage page = loadPage(html);
page.getHtmlElementById("t").type("ab");
assertEquals("input event for type=" + type, "inputinput", page.getTitleText());
}
}
}
Loading