Skip to content

Commit f0260fd

Browse files
committed
Core: Move data selector from core into its own module
Ref #9647
1 parent 3d71fb8 commit f0260fd

File tree

6 files changed

+45
-13
lines changed

6 files changed

+45
-13
lines changed

tests/unit/core/selector.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
define( [
22
"jquery",
3-
"ui/core"
3+
"ui/core",
4+
"ui/data"
45
], function( $ ) {
56

67
module( "core - selectors" );

ui/button.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
define([
2424
"jquery",
2525
"./core",
26+
"./data",
2627
"./version",
2728
"./widget"
2829
], factory );

ui/core.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
// AMD. Register as an anonymous module.
2121
define( [
2222
"jquery",
23+
"./data",
2324
"./version" ], factory );
2425
} else {
2526

@@ -207,17 +208,6 @@ function visible( element ) {
207208
}
208209

209210
$.extend( $.expr[ ":" ], {
210-
data: $.expr.createPseudo ?
211-
$.expr.createPseudo( function( dataName ) {
212-
return function( elem ) {
213-
return !!$.data( elem, dataName );
214-
};
215-
} ) :
216-
// support: jQuery <1.8
217-
function( elem, i, match ) {
218-
return !!$.data( elem, match[ 3 ] );
219-
},
220-
221211
focusable: function( element ) {
222212
return focusable( element, $.attr( element, "tabindex" ) != null );
223213
},

ui/data.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*!
2+
* jQuery UI :data @VERSION
3+
* http://jqueryui.com
4+
*
5+
* Copyright jQuery Foundation and other contributors
6+
* Released under the MIT license.
7+
* http://jquery.org/license
8+
*/
9+
10+
//>>label: :data
11+
//>>group: Core
12+
//>>description: Selects elements which have data stored under the specified key.
13+
//>>docs: http://api.jqueryui.com/data-selector/
14+
15+
( function( factory ) {
16+
if ( typeof define === "function" && define.amd ) {
17+
18+
// AMD. Register as an anonymous module.
19+
define( [ "jquery", "./version" ], factory );
20+
} else {
21+
22+
// Browser globals
23+
factory( jQuery );
24+
}
25+
} ( function( $ ) {
26+
return $.extend( $.expr[ ":" ], {
27+
data: $.expr.createPseudo ?
28+
$.expr.createPseudo( function( dataName ) {
29+
return function( elem ) {
30+
return !!$.data( elem, dataName );
31+
};
32+
} ) :
33+
// support: jQuery <1.8
34+
function( elem, i, match ) {
35+
return !!$.data( elem, match[ 3 ] );
36+
}
37+
} );
38+
} ) );

ui/draggable.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@
2121
define([
2222
"jquery",
2323
"./core",
24-
"./version",
24+
"./data",
2525
"./mouse",
26+
"./version",
2627
"./widget"
2728
], factory );
2829
} else {

ui/sortable.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
define([
2222
"jquery",
2323
"./core",
24+
"./data",
2425
"./mouse",
2526
"./version",
2627
"./widget"

0 commit comments

Comments
 (0)