@yuneta/gobj-ui 7.7.0 → 7.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7493,13 +7493,8 @@ function field_validation_message($input) {
7493
7493
  ************************************************************/
7494
7494
  function mark_field_validity($input) {
7495
7495
  let $h = $input.parentNode ? $input.parentNode.querySelector(".help") : null;
7496
- let ok = true;
7497
- try {
7498
- ok = $input.checkValidity();
7499
- } catch (e) {
7500
- ok = true;
7501
- }
7502
- if (ok) {
7496
+ let v = $input.validity;
7497
+ if (!v || v.valid) {
7503
7498
  $input.classList.remove("is-danger");
7504
7499
  if ($h) {
7505
7500
  $h.textContent = "";
@@ -7488,13 +7488,8 @@ function field_validation_message($input) {
7488
7488
  ************************************************************/
7489
7489
  function mark_field_validity($input) {
7490
7490
  let $h = $input.parentNode ? $input.parentNode.querySelector(".help") : null;
7491
- let ok = true;
7492
- try {
7493
- ok = $input.checkValidity();
7494
- } catch (e) {
7495
- ok = true;
7496
- }
7497
- if (ok) {
7491
+ let v = $input.validity;
7492
+ if (!v || v.valid) {
7498
7493
  $input.classList.remove("is-danger");
7499
7494
  if ($h) {
7500
7495
  $h.textContent = "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.7.0",
3
+ "version": "7.7.1",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
package/src/c_yui_form.js CHANGED
@@ -1990,12 +1990,16 @@ function field_validation_message($input)
1990
1990
  function mark_field_validity($input)
1991
1991
  {
1992
1992
  let $h = $input.parentNode? $input.parentNode.querySelector('.help') : null;
1993
- let ok = true;
1994
- try {
1995
- ok = $input.checkValidity();
1996
- } catch(e) {
1997
- ok = true; /* not a validatable control */
1998
- }
1993
+
1994
+ /* `validity.valid`, NEVER `checkValidity()`.
1995
+ *
1996
+ * checkValidity() FIRES the `invalid` event, and this function is what
1997
+ * that event's handler calls: one asks the other for ever. It cost a
1998
+ * page full of "too much recursion" the first time Save reported a bad
1999
+ * field. Reading `validity` asks the same question and fires nothing.
2000
+ * A control with no `validity` (a wrapper div) is not invalid. */
2001
+ let v = $input.validity;
2002
+ let ok = !v || v.valid;
1999
2003
 
2000
2004
  if(ok) {
2001
2005
  $input.classList.remove('is-danger');