Skip to content

Commit a98c5e0

Browse files
committed
use hierarchy
1 parent 7ea6042 commit a98c5e0

7 files changed

Lines changed: 46 additions & 16 deletions

File tree

src/main/java/org/htmlunit/html/HtmlButtonInput.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,13 @@ protected boolean isRequiredSupported() {
8383
public boolean willValidate() {
8484
return false;
8585
}
86+
87+
/**
88+
* {@inheritDoc}
89+
*/
90+
@Override
91+
protected boolean isCustomValidityValid() {
92+
return true;
93+
}
94+
8695
}

src/main/java/org/htmlunit/html/HtmlHiddenInput.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,12 @@ protected boolean isRequiredSupported() {
8989
public boolean willValidate() {
9090
return false;
9191
}
92+
93+
/**
94+
* {@inheritDoc}
95+
*/
96+
@Override
97+
protected boolean isCustomValidityValid() {
98+
return true;
99+
}
92100
}

src/main/java/org/htmlunit/html/HtmlImageInput.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
*/
1515
package org.htmlunit.html;
1616

17+
import static org.htmlunit.BrowserVersionFeatures.HTMLINPUT_TYPE_IMAGE_IGNORES_CUSTOM_VALIDITY;
18+
1719
import java.io.File;
1820
import java.io.IOException;
1921
import java.io.InputStream;
@@ -191,7 +193,22 @@ public void setDefaultValue(final String defaultValue) {
191193
*/
192194
@Override
193195
public boolean willValidate() {
194-
return false;
196+
if (hasFeature(HTMLINPUT_TYPE_IMAGE_IGNORES_CUSTOM_VALIDITY)) {
197+
return false;
198+
}
199+
return super.willValidate();
200+
}
201+
202+
/**
203+
* {@inheritDoc}
204+
*/
205+
@Override
206+
protected boolean isCustomValidityValid() {
207+
if (hasFeature(HTMLINPUT_TYPE_IMAGE_IGNORES_CUSTOM_VALIDITY)) {
208+
return true;
209+
}
210+
211+
return super.isCustomValidityValid();
195212
}
196213

197214
/**

src/main/java/org/htmlunit/html/HtmlInput.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@
1414
*/
1515
package org.htmlunit.html;
1616

17-
import static org.htmlunit.BrowserVersionFeatures.HTMLINPUT_TYPE_IMAGE_IGNORES_CUSTOM_VALIDITY;
1817
import static org.htmlunit.BrowserVersionFeatures.HTMLINPUT_TYPE_MONTH_SUPPORTED;
1918
import static org.htmlunit.BrowserVersionFeatures.HTMLINPUT_TYPE_WEEK_SUPPORTED;
2019
import static org.htmlunit.html.HtmlForm.ATTRIBUTE_FORMNOVALIDATE;
2120

2221
import java.net.MalformedURLException;
23-
import java.util.Locale;
2422
import java.util.Map;
2523

2624
import org.apache.commons.logging.Log;
@@ -865,16 +863,7 @@ && isMaxLengthValid() && isMinLengthValid()
865863
}
866864

867865
protected boolean isCustomValidityValid() {
868-
if (isCustomErrorValidityState()) {
869-
final String type = getAttributeDirect(TYPE_ATTRIBUTE).toLowerCase(Locale.ROOT);
870-
if (!"button".equals(type)
871-
&& !"hidden".equals(type)
872-
&& !"reset".equals(type)
873-
&& !("image".equals(type) && hasFeature(HTMLINPUT_TYPE_IMAGE_IGNORES_CUSTOM_VALIDITY))) {
874-
return false;
875-
}
876-
}
877-
return true;
866+
return !isCustomErrorValidityState();
878867
}
879868

880869
@Override

src/main/java/org/htmlunit/html/HtmlResetInput.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,12 @@ protected boolean isRequiredSupported() {
106106
public boolean willValidate() {
107107
return false;
108108
}
109+
110+
/**
111+
* {@inheritDoc}
112+
*/
113+
@Override
114+
protected boolean isCustomValidityValid() {
115+
return true;
116+
}
109117
}

src/test/java/org/htmlunit/javascript/host/html/HTMLInputElementTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3549,9 +3549,8 @@ public void clearCustomValidity_restoresValid() throws Exception {
35493549
//
35503550
// loadPageVerifyTitle2(html);
35513551
// }
3552-
35533552
/**
3554-
* reportValidity() is untested anywhere in this file -- basic coverage that
3553+
* The reportValidity() is untested anywhere in this file -- basic coverage that
35553554
* it returns the same boolean as checkValidity() for an input with a custom
35563555
* validity message set.
35573556
* @throws Exception if the test fails

src/test/java/org/htmlunit/javascript/host/html/HTMLObjectElement2Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public void setCustomValidityDoesNotAffectCheckValidity() throws Exception {
211211

212212
loadPageVerifyTitle2(html);
213213
}
214-
//
214+
215215
// /**
216216
// * The validationMessage must always be empty on an <object>, even with a
217217
// * custom validity message set and even when additionally barred via an

0 commit comments

Comments
 (0)