Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Adds src/deprecated.js, test/unit/deprecated.js; -deprecated flag; Mo…
…ves jQuery.browser and removes use in test/unit/ajax.js. Fixes #11965
- Loading branch information
Showing
9 changed files
with
100 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -95,6 +95,12 @@ Exclude **css**: | ||
grunt custom:-css | ||
``` | ||
|
||
Exclude **deprecated**: | ||
|
||
```bash | ||
grunt custom:-deprecated | ||
``` | ||
|
||
Exclude **dimensions**: | ||
|
||
```bash | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,41 @@ | ||
// Limit scope pollution from any deprecated API | ||
(function() { | ||
|
||
var matched, browser; | ||
|
||
// Use of jQuery.browser is frowned upon. | ||
// More details: http://api.jquery.com/jQuery.browser | ||
// jQuery.uaMatch maintained for back-compat | ||
jQuery.uaMatch = function( ua ) { | ||
ua = ua.toLowerCase(); | ||
|
||
var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) || | ||
/(webkit)[ \/]([\w.]+)/.exec( ua ) || | ||
/(opera)(?:.*version)?[ \/]([\w.]+)/.exec( ua ) || | ||
/(msie) ([\w.]+)/.exec( ua ) || | ||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+))?/.exec( ua ) || | ||
[]; | ||
|
||
return { | ||
browser: match[ 1 ] || "", | ||
version: match[ 2 ] || "0" | ||
}; | ||
}; | ||
|
||
matched = jQuery.uaMatch( navigator.userAgent ); | ||
browser = {}; | ||
|
||
if ( matched.browser ) { | ||
browser[ matched.browser ] = true; | ||
browser.version = matched.version; | ||
} | ||
|
||
// Deprecated, use jQuery.browser.webkit instead | ||
// Maintained for back-compat only | ||
if ( browser.webkit ) { | ||
browser.safari = true; | ||
} | ||
|
||
jQuery.browser = browser; | ||
|
||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,28 @@ | ||
module("deprecated"); | ||
|
||
// Start jQuery.browser tests | ||
if ( jQuery.browser && jQuery.uaMatch ) { | ||
if ( jQuery.get && !isLocal ) { | ||
asyncTest( "browser", function() { | ||
jQuery.get( "data/ua.txt", function( data ) { | ||
var uas = data.split( "\n" ); | ||
expect( (uas.length - 1) * 2 ); | ||
|
||
jQuery.each(uas, function() { | ||
var parts = this.split( "\t" ), | ||
agent = parts[2], | ||
ua; | ||
|
||
if ( agent ) { | ||
ua = jQuery.uaMatch( agent ); | ||
equal( ua.browser, parts[0], "browser (" + agent + ")" ); | ||
equal( ua.version, parts[1], "version (" + agent + ")" ); | ||
} | ||
}); | ||
|
||
start(); | ||
}); | ||
}); | ||
} | ||
} | ||
// End of jQuery.browser tests |