Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
6f4b08cd
Commit
6f4b08cd
authored
Feb 14, 2009
by
John Resig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for sorting in Safari - when querySelectorAll isn't able to be used.
parent
d75c899f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
3 deletions
+17
-3
core.js
src/core.js
+4
-2
selector.js
src/selector.js
+11
-0
selector.js
test/unit/selector.js
+2
-1
No files found.
src/core.js
View file @
6f4b08cd
...
@@ -75,7 +75,9 @@ jQuery.fn = jQuery.prototype = {
...
@@ -75,7 +75,9 @@ jQuery.fn = jQuery.prototype = {
this
.
context
=
selector
.
context
;
this
.
context
=
selector
.
context
;
}
}
return
this
.
setArray
(
jQuery
.
makeArray
(
selector
));
return
this
.
setArray
(
jQuery
.
isArray
(
selector
)
?
selector
:
jQuery
.
makeArray
(
selector
));
},
},
// Start with an empty selector
// Start with an empty selector
...
@@ -95,7 +97,7 @@ jQuery.fn = jQuery.prototype = {
...
@@ -95,7 +97,7 @@ jQuery.fn = jQuery.prototype = {
return
num
===
undefined
?
return
num
===
undefined
?
// Return a 'clean' array
// Return a 'clean' array
jQuery
.
makeArray
(
this
)
:
Array
.
prototype
.
slice
.
call
(
this
)
:
// Return just the object
// Return just the object
this
[
num
];
this
[
num
];
...
...
src/selector.js
View file @
6f4b08cd
...
@@ -679,6 +679,17 @@ if ( document.documentElement.compareDocumentPosition ) {
...
@@ -679,6 +679,17 @@ if ( document.documentElement.compareDocumentPosition ) {
}
}
return
ret
;
return
ret
;
};
};
}
else
if
(
Array
.
prototype
.
indexOf
)
{
var
indexOf
=
Array
.
prototype
.
indexOf
,
allSort
=
document
.
getElementsByTagName
(
"*"
);
sortOrder
=
function
(
a
,
b
)
{
var
ret
=
indexOf
.
call
(
allSort
,
a
)
-
indexOf
.
call
(
allSort
,
b
);
if
(
ret
===
0
)
{
hasDuplicate
=
true
;
}
return
ret
;
};
}
}
// Check to see if the browser returns elements by name when
// Check to see if the browser returns elements by name when
...
...
test/unit/selector.js
View file @
6f4b08cd
module
(
"selector"
);
module
(
"selector"
);
test
(
"element"
,
function
()
{
test
(
"element"
,
function
()
{
expect
(
1
3
);
expect
(
1
4
);
reset
();
reset
();
ok
(
jQuery
(
"*"
).
size
()
>=
30
,
"Select all"
);
ok
(
jQuery
(
"*"
).
size
()
>=
30
,
"Select all"
);
...
@@ -24,6 +24,7 @@ test("element", function() {
...
@@ -24,6 +24,7 @@ test("element", function() {
isSet
(
jQuery
(
"p"
),
jQuery
(
"p, div p"
),
"Check for duplicates: p, div p"
);
isSet
(
jQuery
(
"p"
),
jQuery
(
"p, div p"
),
"Check for duplicates: p, div p"
);
t
(
"Checking sort order"
,
"h2, h1"
,
[
"header"
,
"banner"
,
"userAgent"
]
);
t
(
"Checking sort order"
,
"h2, h1"
,
[
"header"
,
"banner"
,
"userAgent"
]
);
t
(
"Checking sort order"
,
"h2:first, h1:first"
,
[
"header"
,
"banner"
]
);
t
(
"Checking sort order"
,
"p, p a"
,
[
"firstp"
,
"simon1"
,
"ap"
,
"google"
,
"groups"
,
"anchor1"
,
"mark"
,
"sndp"
,
"en"
,
"yahoo"
,
"sap"
,
"anchor2"
,
"simon"
,
"first"
]
);
t
(
"Checking sort order"
,
"p, p a"
,
[
"firstp"
,
"simon1"
,
"ap"
,
"google"
,
"groups"
,
"anchor1"
,
"mark"
,
"sndp"
,
"en"
,
"yahoo"
,
"sap"
,
"anchor2"
,
"simon"
,
"first"
]
);
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment