File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -117,7 +117,7 @@ class Pattern extends BasePattern {
117
117
const validity_state = input . validity ;
118
118
119
119
if ( event ?. submitter ?. hasAttribute ( "formnovalidate" ) ) {
120
- // Do not submit when a button with ``formnovalidate`` was used.
120
+ // Do not check when a button with ``formnovalidate`` was used.
121
121
return ;
122
122
}
123
123
@@ -402,7 +402,10 @@ class Pattern extends BasePattern {
402
402
403
403
let did_disable = false ;
404
404
for ( const it of this . disabled_elements ) {
405
- if ( ! it . disabled ) {
405
+ // Disable for melements if they are not already disabled and which
406
+ // do not have set the `formnovalidate` attribute, e.g.
407
+ // `<button formnovalidate>cancel</button>`.
408
+ if ( ! it . disabled && ! it . formNoValidate ) {
406
409
did_disable = true ;
407
410
it . setAttribute ( "disabled" , "disabled" ) ;
408
411
it . classList . add ( "disabled" ) ;
Original file line number Diff line number Diff line change @@ -466,7 +466,9 @@ describe("pat-validation", function () {
466
466
<form class="pat-validation">
467
467
<input name="i1" required>
468
468
<input name="i2" required>
469
- <button>submit</button> <!-- button will be disabled -->
469
+ <button name="b1">submit</button> <!-- button will be disabled -->
470
+ <button name="b2" formnovalidate>more submit</button> <!-- button will NOT be disabled -->
471
+ <button name="b3">even more submit</button> <!-- button will be disabled -->
470
472
</form>
471
473
` ;
472
474
const el = document . querySelector ( ".pat-validation" ) ;
@@ -478,6 +480,9 @@ describe("pat-validation", function () {
478
480
await utils . timeout ( 1 ) ; // wait a tick for async to settle.
479
481
480
482
expect ( el . querySelectorAll ( "em.warning" ) . length ) . toBe ( 2 ) ;
483
+ expect ( el . querySelector ( "[name=b1]" ) . disabled ) . toBe ( true ) ;
484
+ expect ( el . querySelector ( "[name=b2]" ) . disabled ) . toBe ( false ) ;
485
+ expect ( el . querySelector ( "[name=b3]" ) . disabled ) . toBe ( true ) ;
481
486
} ) ;
482
487
483
488
it ( "1.20 - does not validate all inputs after one failed check and no disabled button" , async function ( ) {
You can’t perform that action at this time.
0 commit comments