Skip to content

Commit 64076ec

Browse files
committed
Core: Move form method into its own module
Ref #9647
1 parent 47188b7 commit 64076ec

4 files changed

Lines changed: 24 additions & 9 deletions

File tree

tests/unit/core/core.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
define( [
22
"jquery",
33
"lib/common",
4-
"ui/core"
4+
"ui/core",
5+
"ui/form"
56
], function( $, common ) {
67

78
module( "core - jQuery extensions" );

ui/core.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"./disable-selection",
2525
"./escape-selector",
2626
"./focusable",
27+
"./form",
2728
"./version"
2829
], factory );
2930
} else {
@@ -131,13 +132,6 @@ $.fn.extend( {
131132
} );
132133
},
133134

134-
// Support: IE8 Only
135-
// IE8 does not support the form attribute and when it is supplied. It overwrites the form prop
136-
// with a string, so we need to find the proper form.
137-
form: function() {
138-
return typeof this[ 0 ].form === "string" ? this.closest( "form" ) : $( this[ 0 ].form );
139-
},
140-
141135
labels: function() {
142136
var ancestor, selector, id, labels, ancestors;
143137

ui/form-reset-mixin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// AMD. Register as an anonymous module.
55
define( [
66
"jquery",
7-
"ui/core",
7+
"./form",
88
"./version"
99
], factory );
1010
} else {

ui/form.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
( function( factory ) {
2+
if ( typeof define === "function" && define.amd ) {
3+
4+
// AMD. Register as an anonymous module.
5+
define( [ "jquery", "./version" ], factory );
6+
} else {
7+
8+
// Browser globals
9+
factory( jQuery );
10+
}
11+
} ( function( $ ) {
12+
13+
// Support: IE8 Only
14+
// IE8 does not support the form attribute and when it is supplied. It overwrites the form prop
15+
// with a string, so we need to find the proper form.
16+
return $.fn.form = function() {
17+
return typeof this[ 0 ].form === "string" ? this.closest( "form" ) : $( this[ 0 ].form );
18+
};
19+
20+
} ) );

0 commit comments

Comments
 (0)