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
57652eec
Commit
57652eec
authored
Dec 09, 2014
by
Timmy Willison
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Build: fix tests in AMD mode
parent
828a718a
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
31 additions
and
34 deletions
+31
-34
build.js
build/tasks/build.js
+5
-8
.jshintrc
src/.jshintrc
+3
-2
global.js
src/exports/global.js
+1
-7
jquery.js
src/jquery.js
+2
-3
outro.js
src/outro.js
+1
-0
testinit.js
test/data/testinit.js
+3
-1
core.js
test/unit/core.js
+16
-13
No files found.
build/tasks/build.js
View file @
57652eec
...
...
@@ -26,7 +26,7 @@ module.exports = function( grunt ) {
skipSemiColonInsertion
:
true
,
wrap
:
{
startFile
:
"src/intro.js"
,
endFile
:
"src/outro.js"
endFile
:
[
"src/exports/global.js"
,
"src/outro.js"
]
},
paths
:
{
sizzle
:
"../external/sizzle/dist/sizzle"
...
...
@@ -61,13 +61,10 @@ module.exports = function( grunt ) {
}
else
{
// Ignore jQuery's exports (the only necessary one)
if
(
name
!==
"jquery"
)
{
contents
=
contents
.
replace
(
/
\s
*return
\s
+
[^\}]
+
(\}\)
;
[^\w\}]
*
)
$/
,
"$1"
)
// Multiple exports
.
replace
(
/
\s
*exports
\.\w
+
\s
*=
\s
*
\w
+;/g
,
""
);
}
contents
=
contents
.
replace
(
/
\s
*return
\s
+
[^\}]
+
(\}\)
;
[^\w\}]
*
)
$/
,
"$1"
)
// Multiple exports
.
replace
(
/
\s
*exports
\.\w
+
\s
*=
\s
*
\w
+;/g
,
""
);
// Remove define wrappers, closure ends, and empty declarations
contents
=
contents
...
...
src/.jshintrc
View file @
57652eec
...
...
@@ -21,7 +21,8 @@
"globals": {
"jQuery": true,
"define": true,
"module": true
"define": false,
"module": false,
"noGlobal": true
}
}
src/exports/global.js
View file @
57652eec
define
([
"../core"
],
function
(
jQuery
)
{
var
// Map over jQuery in case of overwrite
_jQuery
=
window
.
jQuery
,
...
...
@@ -24,8 +20,6 @@ jQuery.noConflict = function( deep ) {
// Expose jQuery and $ identifiers, even in
// AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
// and CommonJS for browser emulators (#13566)
if
(
typeof
noGlobal
===
"undefined"
)
{
if
(
!
noGlobal
)
{
window
.
jQuery
=
window
.
$
=
jQuery
;
}
});
src/jquery.js
View file @
57652eec
...
...
@@ -29,10 +29,9 @@ define([
"./offset"
,
"./dimensions"
,
"./deprecated"
,
"./exports/amd"
,
"./exports/global"
"./exports/amd"
],
function
(
jQuery
)
{
return
jQuery
;
return
(
window
.
jQuery
=
window
.
$
=
jQuery
)
;
});
src/outro.js
View file @
57652eec
return
jQuery
;
}));
test/data/testinit.js
View file @
57652eec
...
...
@@ -304,7 +304,9 @@ this.loadTests = function() {
/**
* Run in noConflict mode
*/
jQuery
.
noConflict
();
if
(
jQuery
.
noConflict
)
{
jQuery
.
noConflict
();
}
// Load the TestSwarm listener if swarmURL is in the address.
if
(
loadSwarm
)
{
...
...
test/unit/core.js
View file @
57652eec
...
...
@@ -226,24 +226,27 @@ test( "globalEval execution after script injection (#7862)", 1, function() {
ok
(
window
.
strictEvalTest
-
now
<
500
,
"Code executed synchronously"
);
});
test
(
"noConflict"
,
function
()
{
expect
(
7
);
// This is not run in AMD mode
if
(
jQuery
.
noConflict
)
{
test
(
"noConflict"
,
function
()
{
expect
(
7
);
var
$$
=
jQuery
;
var
$$
=
jQuery
;
strictEqual
(
jQuery
,
jQuery
.
noConflict
(),
"noConflict returned the jQuery object"
);
strictEqual
(
window
[
"jQuery"
],
$$
,
"Make sure jQuery wasn't touched."
);
strictEqual
(
window
[
"$"
],
original$
,
"Make sure $ was reverted."
);
strictEqual
(
jQuery
,
jQuery
.
noConflict
(),
"noConflict returned the jQuery object"
);
strictEqual
(
window
[
"jQuery"
],
$$
,
"Make sure jQuery wasn't touched."
);
strictEqual
(
window
[
"$"
],
original$
,
"Make sure $ was reverted."
);
jQuery
=
$
=
$$
;
jQuery
=
$
=
$$
;
strictEqual
(
jQuery
.
noConflict
(
true
),
$$
,
"noConflict returned the jQuery object"
);
strictEqual
(
window
[
"jQuery"
],
originaljQuery
,
"Make sure jQuery was reverted."
);
strictEqual
(
window
[
"$"
],
original$
,
"Make sure $ was reverted."
);
ok
(
$$
().
pushStack
([]),
"Make sure that jQuery still works."
);
strictEqual
(
jQuery
.
noConflict
(
true
),
$$
,
"noConflict returned the jQuery object"
);
strictEqual
(
window
[
"jQuery"
],
originaljQuery
,
"Make sure jQuery was reverted."
);
strictEqual
(
window
[
"$"
],
original$
,
"Make sure $ was reverted."
);
ok
(
$$
().
pushStack
([]),
"Make sure that jQuery still works."
);
window
[
"jQuery"
]
=
jQuery
=
$$
;
});
window
[
"jQuery"
]
=
jQuery
=
$$
;
});
}
test
(
"trim"
,
function
()
{
expect
(
13
);
...
...
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