@@ -39,8 +39,12 @@ class Pattern extends BasePattern {
3939 static parser = parser ;
4040
4141 init ( ) {
42+ // The element is the form - make it clearer in the code what we're
43+ // referring to.
44+ this . form = this . el ;
45+
4246 events . add_event_listener (
43- this . el ,
47+ this . form ,
4448 "submit" ,
4549 `pat-validation--submit--validator` ,
4650 ( e ) => {
@@ -59,21 +63,21 @@ class Pattern extends BasePattern {
5963 ) ;
6064
6165 this . initialize_inputs ( ) ;
62- $ ( this . el ) . on ( "pat-update" , ( ) => {
66+ $ ( this . form ) . on ( "pat-update" , ( ) => {
6367 this . initialize_inputs ( ) ;
6468 } ) ;
6569
6670 // Set ``novalidate`` attribute to disable the browser's validation
6771 // bubbles but not disable the validation API.
68- this . el . setAttribute ( "novalidate" , "" ) ;
72+ this . form . setAttribute ( "novalidate" , "" ) ;
6973 }
7074
7175 initialize_inputs ( ) {
7276 this . inputs = [
73- ...this . el . querySelectorAll ( "input[name], select[name], textarea[name]" ) ,
77+ ...this . form . querySelectorAll ( "input[name], select[name], textarea[name]" ) ,
7478 ] ;
7579 this . disabled_elements = [
76- ...this . el . querySelectorAll ( this . options . disableSelector ) ,
80+ ...this . form . querySelectorAll ( this . options . disableSelector ) ,
7781 ] ;
7882
7983 for ( const [ cnt , input ] of this . inputs . entries ( ) ) {
@@ -132,7 +136,7 @@ class Pattern extends BasePattern {
132136
133137 if (
134138 input_options . equality &&
135- this . el . querySelector ( `[name=${ input_options . equality } ]` ) ?. value !==
139+ this . form . querySelector ( `[name=${ input_options . equality } ]` ) ?. value !==
136140 input . value
137141 ) {
138142 const message =
@@ -361,7 +365,7 @@ class Pattern extends BasePattern {
361365 }
362366
363367 // disable selector
364- if ( this . el . checkValidity ( ) ) {
368+ if ( this . form . checkValidity ( ) ) {
365369 for ( const it of this . disabled_elements ) {
366370 if ( it . disabled ) {
367371 it . removeAttribute ( "disabled" ) ;
0 commit comments