Skip to content

Commit 6b14cef

Browse files
committed
Remove APIs now in jquery-compat
1 parent 0ee9415 commit 6b14cef

File tree

3 files changed

+3
-265
lines changed

3 files changed

+3
-265
lines changed

src/core.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ var
88
// Use the correct document accordingly with window argument (sandbox)
99
document = window.document,
1010
location = window.location,
11-
navigator = window.navigator,
1211

1312
// Map over jQuery in case of overwrite
1413
_jQuery = window.jQuery,

src/deprecated.js

Lines changed: 2 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,127 +1,4 @@
11
// Limit scope pollution from any deprecated API
2-
(function() {
2+
// (function() {
33

4-
var matched, browser, eventAdd, eventRemove,
5-
oldToggle = jQuery.fn.toggle,
6-
rhoverHack = /(?:^|\s)hover(\.\S+|)\b/,
7-
hoverHack = function( events ) {
8-
return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
9-
};
10-
11-
// Use of jQuery.browser is frowned upon.
12-
// More details: http://api.jquery.com/jQuery.browser
13-
// jQuery.uaMatch maintained for back-compat
14-
jQuery.uaMatch = function( ua ) {
15-
ua = ua.toLowerCase();
16-
17-
var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
18-
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
19-
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
20-
/(msie) ([\w.]+)/.exec( ua ) ||
21-
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
22-
[];
23-
24-
return {
25-
browser: match[ 1 ] || "",
26-
version: match[ 2 ] || "0"
27-
};
28-
};
29-
30-
matched = jQuery.uaMatch( navigator.userAgent );
31-
browser = {};
32-
33-
if ( matched.browser ) {
34-
browser[ matched.browser ] = true;
35-
browser.version = matched.version;
36-
}
37-
38-
// Chrome is Webkit, but Webkit is also Safari.
39-
if ( browser.chrome ) {
40-
browser.webkit = true;
41-
} else if ( browser.webkit ) {
42-
browser.safari = true;
43-
}
44-
45-
jQuery.browser = browser;
46-
47-
jQuery.sub = function() {
48-
function jQuerySub( selector, context ) {
49-
return new jQuerySub.fn.init( selector, context );
50-
}
51-
jQuery.extend( true, jQuerySub, this );
52-
jQuerySub.superclass = this;
53-
jQuerySub.fn = jQuerySub.prototype = this();
54-
jQuerySub.fn.constructor = jQuerySub;
55-
jQuerySub.sub = this.sub;
56-
jQuerySub.fn.init = function init( selector, context ) {
57-
if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
58-
context = jQuerySub( context );
59-
}
60-
61-
return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
62-
};
63-
jQuerySub.fn.init.prototype = jQuerySub.fn;
64-
var rootjQuerySub = jQuerySub(document);
65-
return jQuerySub;
66-
};
67-
68-
jQuery.fn.toggle = function( fn, fn2 ) {
69-
70-
if ( !jQuery.isFunction( fn ) || !jQuery.isFunction( fn2 ) ) {
71-
return oldToggle.apply( this, arguments );
72-
}
73-
74-
// Save reference to arguments for access in closure
75-
var args = arguments,
76-
guid = fn.guid || jQuery.guid++,
77-
i = 0,
78-
toggler = function( event ) {
79-
// Figure out which function to execute
80-
var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
81-
jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
82-
83-
// Make sure that clicks stop
84-
event.preventDefault();
85-
86-
// and execute the function
87-
return args[ lastToggle ].apply( this, arguments ) || false;
88-
};
89-
90-
// link all the functions, so any of them can unbind this click handler
91-
toggler.guid = guid;
92-
while ( i < args.length ) {
93-
args[ i++ ].guid = guid;
94-
}
95-
96-
return this.click( toggler );
97-
};
98-
99-
100-
// Support for 'hover' type
101-
eventAdd = jQuery.event.add;
102-
103-
// Duck punch jQuery.event.add, and jquery.event.remove
104-
// Signatures:
105-
// jQuery.event = {
106-
// add: function( elem, types, handler, data, selector ) {
107-
// remove: function( elem, types, handler, selector, mappedTypes ) {
108-
jQuery.event.add = function( elem, types, handler, data, selector ){
109-
if ( types ) {
110-
types = hoverHack( types );
111-
}
112-
eventAdd.call( this, elem, types, handler, data, selector );
113-
};
114-
115-
eventRemove = jQuery.event.remove;
116-
117-
jQuery.event.remove = function( elem, types, handler, selector, mappedTypes ){
118-
if ( types ) {
119-
types = hoverHack( types );
120-
}
121-
eventRemove.call( this, elem, types, handler, selector, mappedTypes );
122-
};
123-
124-
// Unused in 1.8, left in so attrFn-stabbers won't die; remove in 1.9
125-
jQuery.attrFn = {};
126-
127-
})();
4+
// })();

test/unit/deprecated.js

Lines changed: 1 addition & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -1,139 +1 @@
1-
if ( jQuery.browser ) {
2-
module("deprecated");
3-
4-
if ( jQuery.get && !isLocal ) {
5-
asyncTest( "browser", function() {
6-
jQuery.get( "data/ua.txt", function( data ) {
7-
var uas = data.split( "\n" );
8-
expect( (uas.length - 1) * 2 );
9-
10-
jQuery.each(uas, function() {
11-
var parts = this.split( "\t" ),
12-
agent = parts[2],
13-
ua;
14-
15-
if ( agent ) {
16-
ua = jQuery.uaMatch( agent );
17-
equal( ua.browser, parts[0], "browser (" + agent + ")" );
18-
equal( ua.version, parts[1], "version (" + agent + ")" );
19-
}
20-
});
21-
22-
start();
23-
});
24-
});
25-
}
26-
27-
test("toggle(Function, Function, ...)", function() {
28-
expect(16);
29-
30-
var count = 0,
31-
fn1 = function(e) { count++; },
32-
fn2 = function(e) { count--; },
33-
preventDefault = function(e) { e.preventDefault(); },
34-
link = jQuery("#mark");
35-
link.click(preventDefault).click().toggle(fn1, fn2).click().click().click().click().click();
36-
equal( count, 1, "Check for toggle(fn, fn)" );
37-
38-
jQuery("#firstp").toggle(function () {
39-
equal(arguments.length, 4, "toggle correctly passes through additional triggered arguments, see #1701" );
40-
}, function() {}).trigger("click", [ 1, 2, 3 ]);
41-
42-
var first = 0;
43-
jQuery("#simon1").one("click", function() {
44-
ok( true, "Execute event only once" );
45-
jQuery(this).toggle(function() {
46-
equal( first++, 0, "toggle(Function,Function) assigned from within one('xxx'), see #1054" );
47-
}, function() {
48-
equal( first, 1, "toggle(Function,Function) assigned from within one('xxx'), see #1054" );
49-
});
50-
return false;
51-
}).click().click().click();
52-
53-
var turn = 0;
54-
var fns = [
55-
function(){
56-
turn = 1;
57-
},
58-
function(){
59-
turn = 2;
60-
},
61-
function(){
62-
turn = 3;
63-
}
64-
];
65-
66-
var $div = jQuery("<div>&nbsp;</div>").toggle( fns[0], fns[1], fns[2] );
67-
$div.click();
68-
equal( turn, 1, "Trying toggle with 3 functions, attempt 1 yields 1");
69-
$div.click();
70-
equal( turn, 2, "Trying toggle with 3 functions, attempt 2 yields 2");
71-
$div.click();
72-
equal( turn, 3, "Trying toggle with 3 functions, attempt 3 yields 3");
73-
$div.click();
74-
equal( turn, 1, "Trying toggle with 3 functions, attempt 4 yields 1");
75-
$div.click();
76-
equal( turn, 2, "Trying toggle with 3 functions, attempt 5 yields 2");
77-
78-
$div.unbind("click",fns[0]);
79-
var data = jQuery._data( $div[0], "events" );
80-
ok( !data, "Unbinding one function from toggle unbinds them all");
81-
82-
// manually clean up detached elements
83-
$div.remove();
84-
85-
// Test Multi-Toggles
86-
var a = [], b = [];
87-
$div = jQuery("<div/>");
88-
$div.toggle(function(){ a.push(1); }, function(){ a.push(2); });
89-
$div.click();
90-
deepEqual( a, [1], "Check that a click worked." );
91-
92-
$div.toggle(function(){ b.push(1); }, function(){ b.push(2); });
93-
$div.click();
94-
deepEqual( a, [1,2], "Check that a click worked with a second toggle." );
95-
deepEqual( b, [1], "Check that a click worked with a second toggle." );
96-
97-
$div.click();
98-
deepEqual( a, [1,2,1], "Check that a click worked with a second toggle, second click." );
99-
deepEqual( b, [1,2], "Check that a click worked with a second toggle, second click." );
100-
101-
// manually clean up detached elements
102-
$div.remove();
103-
});
104-
105-
test("attrFn test", function() {
106-
expect(1);
107-
ok(!!jQuery.attrFn, "attrFnPresent");
108-
});
109-
110-
test("hover pseudo-event", function() {
111-
expect(2);
112-
113-
var balance = 0;
114-
jQuery( "#firstp" )
115-
.on( "hovercraft", function() {
116-
ok( false, "hovercraft is full of ills" );
117-
})
118-
.on( "click.hover.me.not", function( e ) {
119-
equal( e.handleObj.namespace, "hover.me.not", "hover hack doesn't mangle namespaces" );
120-
})
121-
.bind("hover", function( e ) {
122-
if ( e.type === "mouseenter" ) {
123-
balance++;
124-
} else if ( e.type === "mouseleave" ) {
125-
balance--;
126-
} else {
127-
ok( false, "hover pseudo: unknown event type "+e.type );
128-
}
129-
})
130-
.trigger("click")
131-
.trigger("mouseenter")
132-
.trigger("mouseleave")
133-
.unbind("hover")
134-
.trigger("mouseenter");
135-
136-
equal( balance, 0, "hover pseudo-event" );
137-
});
138-
139-
}
1+
module("deprecated");

0 commit comments

Comments
 (0)