Removed all deprecated functionality for jQuery 1.2. A full list of what was removed can be found here: http://jquery.com/blog/2007/08/24/jquery-114-faster-more-tests-ready-for-12/
This commit is contained in:
parent
139393fe09
commit
53dc6afc31
6 changed files with 85 additions and 180 deletions
|
@ -2,7 +2,7 @@
|
|||
var chars = jQuery.browser.safari && parseInt(jQuery.browser.version) < 417 ?
|
||||
"(?:[\\w*_-]|\\\\.)" :
|
||||
"(?:[\\w\u0128-\uFFFF*_-]|\\\\.)",
|
||||
quickChild = new RegExp("^[/>]\\s*(" + chars + "+)"),
|
||||
quickChild = new RegExp("^>\\s*(" + chars + "+)"),
|
||||
quickID = new RegExp("^(" + chars + "+)(#)(" + chars + "+)"),
|
||||
quickClass = new RegExp("^([#.]?)(" + chars + "*)");
|
||||
|
||||
|
@ -60,19 +60,13 @@ jQuery.extend({
|
|||
|
||||
// :header
|
||||
header: "/h\\d/i.test(a.nodeName)"
|
||||
},
|
||||
// DEPRECATED
|
||||
"[": "jQuery.find(m[2],a).length"
|
||||
}
|
||||
},
|
||||
|
||||
// The regular expressions that power the parsing engine
|
||||
parse: [
|
||||
// Match: [@value='test'], [@foo]
|
||||
/^\[ *(@)([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/,
|
||||
|
||||
// DEPRECATED
|
||||
// Match: [div], [div p]
|
||||
/^(\[)\s*(.*?(\[.*?\])?[^[]*?)\s*\]/,
|
||||
/^(\[) *@?([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/,
|
||||
|
||||
// Match: :contains('foo')
|
||||
/^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,
|
||||
|
@ -106,21 +100,6 @@ jQuery.extend({
|
|||
// Set the correct context (if none is provided)
|
||||
context = context || document;
|
||||
|
||||
// DEPRECATED
|
||||
// Handle the common XPath // expression
|
||||
if ( !t.indexOf("//") ) {
|
||||
//context = context.documentElement;
|
||||
t = t.substr(2,t.length);
|
||||
|
||||
// DEPRECATED
|
||||
// And the / root expression
|
||||
} else if ( !t.indexOf("/") && !context.ownerDocument ) {
|
||||
context = context.documentElement;
|
||||
t = t.substr(1,t.length);
|
||||
if ( t.indexOf("/") >= 1 )
|
||||
t = t.substr(t.indexOf("/"),t.length);
|
||||
}
|
||||
|
||||
// Initialize the search
|
||||
var ret = [context], done = [], last;
|
||||
|
||||
|
@ -130,8 +109,7 @@ jQuery.extend({
|
|||
var r = [];
|
||||
last = t;
|
||||
|
||||
// DEPRECATED
|
||||
t = jQuery.trim(t).replace( /^\/\//, "" );
|
||||
t = jQuery.trim(t);
|
||||
|
||||
var foundToken = false;
|
||||
|
||||
|
@ -154,32 +132,28 @@ jQuery.extend({
|
|||
if ( t.indexOf(" ") == 0 ) continue;
|
||||
foundToken = true;
|
||||
} else {
|
||||
// (.. and /) DEPRECATED
|
||||
re = /^((\/?\.\.)|([>\/+~]))\s*(\w*)/i;
|
||||
re = /^([>+~])\s*(\w*)/i;
|
||||
|
||||
if ( (m = re.exec(t)) != null ) {
|
||||
r = [];
|
||||
|
||||
var nodeName = m[4], mergeNum = jQuery.mergeNum++;
|
||||
var nodeName = m[2], mergeNum = jQuery.mergeNum++;
|
||||
m = m[1];
|
||||
|
||||
for ( var j = 0, rl = ret.length; j < rl; j++ )
|
||||
if ( m.indexOf("..") < 0 ) {
|
||||
var n = m == "~" || m == "+" ? ret[j].nextSibling : ret[j].firstChild;
|
||||
for ( ; n; n = n.nextSibling )
|
||||
if ( n.nodeType == 1 ) {
|
||||
if ( m == "~" && n.mergeNum == mergeNum ) break;
|
||||
|
||||
if (!nodeName || n.nodeName.toUpperCase() == nodeName.toUpperCase() ) {
|
||||
if ( m == "~" ) n.mergeNum = mergeNum;
|
||||
r.push( n );
|
||||
}
|
||||
|
||||
if ( m == "+" ) break;
|
||||
for ( var j = 0, rl = ret.length; j < rl; j++ ) {
|
||||
var n = m == "~" || m == "+" ? ret[j].nextSibling : ret[j].firstChild;
|
||||
for ( ; n; n = n.nextSibling )
|
||||
if ( n.nodeType == 1 ) {
|
||||
if ( m == "~" && n.mergeNum == mergeNum ) break;
|
||||
|
||||
if (!nodeName || n.nodeName.toUpperCase() == nodeName.toUpperCase() ) {
|
||||
if ( m == "~" ) n.mergeNum = mergeNum;
|
||||
r.push( n );
|
||||
}
|
||||
// DEPRECATED
|
||||
} else
|
||||
r.push( ret[j].parentNode );
|
||||
|
||||
if ( m == "+" ) break;
|
||||
}
|
||||
}
|
||||
|
||||
ret = r;
|
||||
|
||||
|
@ -347,7 +321,7 @@ jQuery.extend({
|
|||
else if ( m[1] == "." )
|
||||
r = jQuery.classFilter(r, m[2], not);
|
||||
|
||||
else if ( m[1] == "@" ) {
|
||||
else if ( m[1] == "[" ) {
|
||||
var tmp = [], type = m[3];
|
||||
|
||||
for ( var i = 0, rl = r.length; i < rl; i++ ) {
|
||||
|
|
|
@ -63,7 +63,7 @@ test("id", function() {
|
|||
t( "ID Selector, not an ancestor ID", "#form #first", [] );
|
||||
t( "ID Selector, not a child ID", "#form > #option1a", [] );
|
||||
|
||||
t( "All Children of ID", "#foo/*", ["sndp", "en", "sap"] );
|
||||
t( "All Children of ID", "#foo > *", ["sndp", "en", "sap"] );
|
||||
t( "All Children of ID with no children", "#firstUL/*", [] );
|
||||
|
||||
$('<a name="tName1">tName1 A</a><a name="tName2">tName2 A</a><div id="tName1">tName1 Div</div>').appendTo('#main');
|
||||
|
@ -134,36 +134,36 @@ test("child and adjacent", function() {
|
|||
|
||||
test("attributes", function() {
|
||||
expect(20);
|
||||
t( "Attribute Exists", "a[@title]", ["google"] );
|
||||
t( "Attribute Exists", "*[@title]", ["google"] );
|
||||
t( "Attribute Exists", "[@title]", ["google"] );
|
||||
t( "Attribute Exists", "a[title]", ["google"] );
|
||||
t( "Attribute Exists", "*[title]", ["google"] );
|
||||
t( "Attribute Exists", "[title]", ["google"] );
|
||||
|
||||
t( "Attribute Equals", "a[@rel='bookmark']", ["simon1"] );
|
||||
t( "Attribute Equals", 'a[@rel="bookmark"]', ["simon1"] );
|
||||
t( "Attribute Equals", "a[@rel=bookmark]", ["simon1"] );
|
||||
t( "Multiple Attribute Equals", "input[@type='hidden'],input[@type='radio']", ["hidden1","radio1","radio2"] );
|
||||
t( "Multiple Attribute Equals", "input[@type=\"hidden\"],input[@type='radio']", ["hidden1","radio1","radio2"] );
|
||||
t( "Multiple Attribute Equals", "input[@type=hidden],input[@type=radio]", ["hidden1","radio1","radio2"] );
|
||||
t( "Attribute Equals", "a[rel='bookmark']", ["simon1"] );
|
||||
t( "Attribute Equals", 'a[rel="bookmark"]', ["simon1"] );
|
||||
t( "Attribute Equals", "a[rel=bookmark]", ["simon1"] );
|
||||
t( "Multiple Attribute Equals", "input[type='hidden'],input[type='radio']", ["hidden1","radio1","radio2"] );
|
||||
t( "Multiple Attribute Equals", "input[type=\"hidden\"],input[type='radio']", ["hidden1","radio1","radio2"] );
|
||||
t( "Multiple Attribute Equals", "input[type=hidden],input[type=radio]", ["hidden1","radio1","radio2"] );
|
||||
|
||||
t( "Attribute selector using UTF8", "span[@lang=中文]", ["台北"] );
|
||||
t( "Attribute selector using UTF8", "span[lang=中文]", ["台北"] );
|
||||
|
||||
t( "Attribute Begins With", "a[@href ^= 'http://www']", ["google","yahoo"] );
|
||||
t( "Attribute Ends With", "a[@href $= 'org/']", ["mark"] );
|
||||
t( "Attribute Contains", "a[@href *= 'google']", ["google","groups"] );
|
||||
t( "Attribute Begins With", "a[href ^= 'http://www']", ["google","yahoo"] );
|
||||
t( "Attribute Ends With", "a[href $= 'org/']", ["mark"] );
|
||||
t( "Attribute Contains", "a[href *= 'google']", ["google","groups"] );
|
||||
|
||||
t("Select options via [@selected]", "#select1 option[@selected]", ["option1a"] );
|
||||
t("Select options via [@selected]", "#select2 option[@selected]", ["option2d"] );
|
||||
t("Select options via [@selected]", "#select3 option[@selected]", ["option3b", "option3c"] );
|
||||
t("Select options via [selected]", "#select1 option[selected]", ["option1a"] );
|
||||
t("Select options via [selected]", "#select2 option[selected]", ["option2d"] );
|
||||
t("Select options via [selected]", "#select3 option[selected]", ["option3b", "option3c"] );
|
||||
|
||||
t( "Grouped Form Elements", "input[@name='foo[bar]']", ["hidden2"] );
|
||||
t( "Grouped Form Elements", "input[name='foo[bar]']", ["hidden2"] );
|
||||
|
||||
t( ":not() Existing attribute", "select:not([@multiple])", ["select1", "select2"]);
|
||||
t( ":not() Equals attribute", "select:not([@name=select1])", ["select2", "select3"]);
|
||||
t( ":not() Equals quoted attribute", "select:not([@name='select1'])", ["select2", "select3"]);
|
||||
t( ":not() Existing attribute", "select:not([multiple])", ["select1", "select2"]);
|
||||
t( ":not() Equals attribute", "select:not([name=select1])", ["select2", "select3"]);
|
||||
t( ":not() Equals quoted attribute", "select:not([name='select1'])", ["select2", "select3"]);
|
||||
});
|
||||
|
||||
test("pseudo (:) selectors", function() {
|
||||
expect(31);
|
||||
expect(32);
|
||||
t( "First Child", "p:first-child", ["firstp","sndp"] );
|
||||
t( "Last Child", "p:last-child", ["sap"] );
|
||||
t( "Only Child", "a:only-child", ["simon1","anchor1","yahoo","anchor2"] );
|
||||
|
@ -198,28 +198,5 @@ test("pseudo (:) selectors", function() {
|
|||
t( "Form element :checkbox:checked, :radio:checked", ":checkbox:checked, :radio:checked", ["check1", "radio2"] );
|
||||
|
||||
t( "Headers", ":header", ["header", "banner", "userAgent"] );
|
||||
});
|
||||
|
||||
test("basic xpath", function() {
|
||||
expect(17);
|
||||
ok( jQuery.find("//*").length >= 30, "All Elements (//*)" );
|
||||
ok( jQuery.find("//div", q("main")[0])[0] = q("foo")[0], "All Relative (#main//div)" );
|
||||
t( "All P Elements", "//p", ["firstp","ap","sndp","en","sap","first"] );
|
||||
t( "Absolute Path", "/html/body", ["body"] );
|
||||
t( "Absolute Path w/ *", "/* /body", ["body"] );
|
||||
t( "Long Absolute Path", "/html/body/dl/div/div/p", ["sndp","en","sap"] );
|
||||
t( "Absolute and Relative Paths", "/html//p", ["firstp","ap","sndp","en","sap","first"] );
|
||||
t( "All Children, Explicit", "//code/*", ["anchor1","anchor2"] );
|
||||
t( "All Children, Implicit", "//code/", ["anchor1","anchor2"] );
|
||||
t( "Attribute Exists", "//a[@title]", ["google"] );
|
||||
t( "Attribute Equals", "//a[@rel='bookmark']", ["simon1"] );
|
||||
t( "Parent Axis", "//p/..", ["main","foo"] );
|
||||
t( "Sibling Axis", "//p/../", ["firstp","ap","foo","first","firstUL","empty","form","floatTest","iframe","lengthtest","table","fx-queue","fx-tests","sndp","en","sap"] );
|
||||
t( "Sibling Axis", "//p/../*", ["firstp","ap","foo","first","firstUL","empty","form","floatTest","iframe","lengthtest","table","fx-queue","fx-tests","sndp","en","sap"] );
|
||||
t( "Has Children", "//p[a]", ["firstp","ap","en","sap"] );
|
||||
t( "Has Children - :has()", "//p:has(a)", ["firstp","ap","en","sap"] );
|
||||
|
||||
$("#foo").each(function() {
|
||||
isSet( $("/p", this).get(), q("sndp", "en", "sap"), "Check XPath context" );
|
||||
});
|
||||
t( "Has Children - :has()", "p:has(a)", ["firstp","ap","en","sap"] );
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue