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 {
117117 const validity_state = input . validity ;
118118
119119 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.
121121 return ;
122122 }
123123
@@ -402,7 +402,10 @@ class Pattern extends BasePattern {
402402
403403 let did_disable = false ;
404404 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 ) {
406409 did_disable = true ;
407410 it . setAttribute ( "disabled" , "disabled" ) ;
408411 it . classList . add ( "disabled" ) ;
Original file line number Diff line number Diff line change @@ -466,7 +466,9 @@ describe("pat-validation", function () {
466466 <form class="pat-validation">
467467 <input name="i1" required>
468468 <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 -->
470472 </form>
471473 ` ;
472474 const el = document . querySelector ( ".pat-validation" ) ;
@@ -478,6 +480,9 @@ describe("pat-validation", function () {
478480 await utils . timeout ( 1 ) ; // wait a tick for async to settle.
479481
480482 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 ) ;
481486 } ) ;
482487
483488 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