Skip to content

Commit

Permalink
Core: Move form method into its own module
Browse files Browse the repository at this point in the history
Ref #9647
  • Loading branch information
arschmitz committed Aug 8, 2015
1 parent 47188b7 commit 64076ec
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
3 changes: 2 additions & 1 deletion tests/unit/core/core.js
@@ -1,7 +1,8 @@
define( [
"jquery",
"lib/common",
"ui/core"
"ui/core",
"ui/form"
], function( $, common ) {

module( "core - jQuery extensions" );
Expand Down
8 changes: 1 addition & 7 deletions ui/core.js
Expand Up @@ -24,6 +24,7 @@
"./disable-selection",
"./escape-selector",
"./focusable",
"./form",
"./version"
], factory );
} else {
Expand Down Expand Up @@ -131,13 +132,6 @@ $.fn.extend( {
} );
},

// Support: IE8 Only
// IE8 does not support the form attribute and when it is supplied. It overwrites the form prop
// with a string, so we need to find the proper form.
form: function() {
return typeof this[ 0 ].form === "string" ? this.closest( "form" ) : $( this[ 0 ].form );
},

labels: function() {
var ancestor, selector, id, labels, ancestors;

Expand Down
2 changes: 1 addition & 1 deletion ui/form-reset-mixin.js
Expand Up @@ -4,7 +4,7 @@
// AMD. Register as an anonymous module.
define( [
"jquery",
"ui/core",
"./form",
"./version"
], factory );
} else {
Expand Down
20 changes: 20 additions & 0 deletions ui/form.js
@@ -0,0 +1,20 @@
( function( factory ) {
if ( typeof define === "function" && define.amd ) {

// AMD. Register as an anonymous module.
define( [ "jquery", "./version" ], factory );
} else {

// Browser globals
factory( jQuery );
}
} ( function( $ ) {

// Support: IE8 Only
// IE8 does not support the form attribute and when it is supplied. It overwrites the form prop
// with a string, so we need to find the proper form.
return $.fn.form = function() {
return typeof this[ 0 ].form === "string" ? this.closest( "form" ) : $( this[ 0 ].form );
};

} ) );

0 comments on commit 64076ec

Please sign in to comment.