@@ -39,8 +39,12 @@ class Pattern extends BasePattern {
39
39
static parser = parser ;
40
40
41
41
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
+
42
46
events . add_event_listener (
43
- this . el ,
47
+ this . form ,
44
48
"submit" ,
45
49
`pat-validation--submit--validator` ,
46
50
( e ) => {
@@ -59,21 +63,21 @@ class Pattern extends BasePattern {
59
63
) ;
60
64
61
65
this . initialize_inputs ( ) ;
62
- $ ( this . el ) . on ( "pat-update" , ( ) => {
66
+ $ ( this . form ) . on ( "pat-update" , ( ) => {
63
67
this . initialize_inputs ( ) ;
64
68
} ) ;
65
69
66
70
// Set ``novalidate`` attribute to disable the browser's validation
67
71
// bubbles but not disable the validation API.
68
- this . el . setAttribute ( "novalidate" , "" ) ;
72
+ this . form . setAttribute ( "novalidate" , "" ) ;
69
73
}
70
74
71
75
initialize_inputs ( ) {
72
76
this . inputs = [
73
- ...this . el . querySelectorAll ( "input[name], select[name], textarea[name]" ) ,
77
+ ...this . form . querySelectorAll ( "input[name], select[name], textarea[name]" ) ,
74
78
] ;
75
79
this . disabled_elements = [
76
- ...this . el . querySelectorAll ( this . options . disableSelector ) ,
80
+ ...this . form . querySelectorAll ( this . options . disableSelector ) ,
77
81
] ;
78
82
79
83
for ( const [ cnt , input ] of this . inputs . entries ( ) ) {
@@ -132,7 +136,7 @@ class Pattern extends BasePattern {
132
136
133
137
if (
134
138
input_options . equality &&
135
- this . el . querySelector ( `[name=${ input_options . equality } ]` ) ?. value !==
139
+ this . form . querySelector ( `[name=${ input_options . equality } ]` ) ?. value !==
136
140
input . value
137
141
) {
138
142
const message =
@@ -361,7 +365,7 @@ class Pattern extends BasePattern {
361
365
}
362
366
363
367
// disable selector
364
- if ( this . el . checkValidity ( ) ) {
368
+ if ( this . form . checkValidity ( ) ) {
365
369
for ( const it of this . disabled_elements ) {
366
370
if ( it . disabled ) {
367
371
it . removeAttribute ( "disabled" ) ;
0 commit comments