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
1ac9d6fb
Commit
1ac9d6fb
authored
Oct 20, 2007
by
John Resig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a fix for .noConflict(true) not reverting properly. Also added unit tests for noConflict.
parent
5736e8d9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
4 deletions
+26
-4
core.js
src/core.js
+4
-4
index.html
test/index.html
+1
-0
core.js
test/unit/core.js
+21
-0
No files found.
src/core.js
View file @
1ac9d6fb
...
...
@@ -10,8 +10,8 @@
*/
// Map over jQuery in case of overwrite
if
(
typeof
jQuery
!=
"undefined"
)
var
_jQuery
=
jQuery
;
if
(
window
.
jQuery
)
var
_jQuery
=
window
.
jQuery
;
var
jQuery
=
window
.
jQuery
=
function
(
selector
,
context
)
{
// If the context is a namespace object, return a new object
...
...
@@ -21,8 +21,8 @@ var jQuery = window.jQuery = function( selector, context ) {
};
// Map over the $ in case of overwrite
if
(
typeof
$
!=
"undefined"
)
var
_$
=
$
;
if
(
window
.
$
)
var
_$
=
window
.
$
;
// Map the jQuery namespace to the '$' one
window
.
$
=
jQuery
;
...
...
test/index.html
View file @
1ac9d6fb
...
...
@@ -4,6 +4,7 @@
<meta
http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
/>
<title>
jQuery Test Suite
</title>
<link
rel=
"Stylesheet"
media=
"screen"
href=
"data/testsuite.css"
/>
<script>
var
jQuery
=
"jQuery"
,
$
=
"$"
;
// For testing .noConflcit()
</script>
<script
type=
"text/javascript"
src=
"../dist/jquery.js"
></script>
<script
type=
"text/javascript"
src=
"data/testrunner.js"
></script>
<script
type=
"text/javascript"
src=
"unit/core.js"
></script>
...
...
test/unit/core.js
View file @
1ac9d6fb
...
...
@@ -38,6 +38,27 @@ test("$()", function() {
equals
(
div
.
length
,
4
,
"Correct number of elements generated for div hr code b"
);
});
test
(
"noConflict"
,
function
()
{
expect
(
6
);
var
old
=
jQuery
;
var
newjQuery
=
jQuery
.
noConflict
();
ok
(
newjQuery
==
old
,
"noConflict returned the jQuery object"
);
ok
(
jQuery
==
old
,
"Make sure jQuery wasn't touched."
);
ok
(
$
==
"$"
,
"Make sure $ was reverted."
);
jQuery
=
$
=
old
;
newjQuery
=
jQuery
.
noConflict
(
true
);
ok
(
newjQuery
==
old
,
"noConflict returned the jQuery object"
);
ok
(
jQuery
==
"jQuery"
,
"Make sure jQuery was reverted."
);
ok
(
$
==
"$"
,
"Make sure $ was reverted."
);
jQuery
=
$
=
old
;
});
test
(
"isFunction"
,
function
()
{
expect
(
21
);
...
...
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