diff options
author | Alexander Schmitz <arschmitz@gmail.com> | 2015-07-16 09:14:58 -0400 |
---|---|---|
committer | Alexander Schmitz <arschmitz@gmail.com> | 2015-08-08 00:29:36 -0400 |
commit | 64076ecfb5870130d89733ff34668fdd18683f9b (patch) | |
tree | 57ee9671983872f4cd92011c7d6b0c1128906a25 | |
parent | 47188b792617a0030ccec07c6df27335dc3aa430 (diff) | |
download | jquery-ui-64076ecfb5870130d89733ff34668fdd18683f9b.tar.gz jquery-ui-64076ecfb5870130d89733ff34668fdd18683f9b.zip |
Core: Move form method into its own module
Ref #9647
-rw-r--r-- | tests/unit/core/core.js | 3 | ||||
-rw-r--r-- | ui/core.js | 8 | ||||
-rw-r--r-- | ui/form-reset-mixin.js | 2 | ||||
-rw-r--r-- | ui/form.js | 20 |
4 files changed, 24 insertions, 9 deletions
diff --git a/tests/unit/core/core.js b/tests/unit/core/core.js index ac9f28e00..0d25e22d8 100644 --- a/tests/unit/core/core.js +++ b/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" ); diff --git a/ui/core.js b/ui/core.js index fe627dea6..fc91c2742 100644 --- a/ui/core.js +++ b/ui/core.js @@ -24,6 +24,7 @@ "./disable-selection", "./escape-selector", "./focusable", + "./form", "./version" ], factory ); } else { @@ -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; diff --git a/ui/form-reset-mixin.js b/ui/form-reset-mixin.js index 423a35538..21704708e 100644 --- a/ui/form-reset-mixin.js +++ b/ui/form-reset-mixin.js @@ -4,7 +4,7 @@ // AMD. Register as an anonymous module. define( [ "jquery", - "ui/core", + "./form", "./version" ], factory ); } else { diff --git a/ui/form.js b/ui/form.js new file mode 100644 index 000000000..cfb4bd280 --- /dev/null +++ b/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 ); +}; + +} ) ); |