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
c68ab270
Commit
c68ab270
authored
Jun 07, 2012
by
Mike Sherov
Committed by
Rick Waldron
Jun 07, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modularize offset (exclude w/ grunt build:*:*:-offset). Closes #813. Fixes #11865
parent
c80bc227
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
110 additions
and
58 deletions
+110
-58
README.md
README.md
+31
-0
grunt.js
grunt.js
+1
-1
attributes.js
test/unit/attributes.js
+36
-25
core.js
test/unit/core.js
+38
-32
offset.js
test/unit/offset.js
+4
-0
No files found.
README.md
View file @
c68ab270
...
@@ -62,6 +62,37 @@ Then, to get a complete, minified (w/ Uglify.js), linted (w/ JSHint) version of
...
@@ -62,6 +62,37 @@ Then, to get a complete, minified (w/ Uglify.js), linted (w/ JSHint) version of
The built version of jQuery will be put in the
`dist/`
subdirectory.
The built version of jQuery will be put in the
`dist/`
subdirectory.
### Modules (new in 1.8)
Starting in jQuery 1.8, special builds can now be created that optionally exlude or include any of the following modules:
-
dimensions
-
effects
-
offset
To create a custom build, use the following special
`grunt`
commands:
Exclude
`dimensions`
:
#### `grunt build:*:*:-dimensions` ####
Exclude
`effects`
:
#### `grunt build:*:*:-effects` ####
Exclude
`offset`
:
#### `grunt build:*:*:-offset` ####
Exclude
**all**
optional modules:
#### `grunt build:*:*:-dimensions:-effects:-offset` ####
Running the Unit Tests
Running the Unit Tests
--------------------------------------
--------------------------------------
...
...
grunt.js
View file @
c68ab270
...
@@ -69,7 +69,7 @@ module.exports = function( grunt ) {
...
@@ -69,7 +69,7 @@ module.exports = function( grunt ) {
"src/ajax/script.js"
,
"src/ajax/script.js"
,
"src/ajax/xhr.js"
,
"src/ajax/xhr.js"
,
{
flag
:
"effects"
,
src
:
"src/effects.js"
},
{
flag
:
"effects"
,
src
:
"src/effects.js"
},
"src/offset.js"
,
{
flag
:
"offset"
,
src
:
"src/offset.js"
}
,
{
flag
:
"dimensions"
,
src
:
"src/dimensions.js"
},
{
flag
:
"dimensions"
,
src
:
"src/dimensions.js"
},
"src/exports.js"
,
"src/exports.js"
,
"src/outro.js"
"src/outro.js"
...
...
test/unit/attributes.js
View file @
c68ab270
...
@@ -368,44 +368,55 @@ test("attr(String, Object)", function() {
...
@@ -368,44 +368,55 @@ test("attr(String, Object)", function() {
});
});
test
(
"attr(jquery_method)"
,
function
(){
test
(
"attr(jquery_method)"
,
function
(){
expect
(
7
);
var
$elem
=
jQuery
(
"<div />"
),
var
$elem
=
jQuery
(
"<div />"
),
elem
=
$elem
[
0
];
elem
=
$elem
[
0
],
expected
=
5
,
attrObj
=
{
css
:
{
paddingLeft
:
1
,
paddingRight
:
1
}
};
if
(
jQuery
.
fn
.
width
)
{
expected
+=
2
;
attrObj
.
width
=
10
;
}
if
(
jQuery
.
fn
.
offset
)
{
expected
+=
2
;
attrObj
.
offset
=
{
top
:
1
,
left
:
0
};
}
expect
(
expected
);
// one at a time
// one at a time
$elem
.
attr
(
{
html
:
"foo"
},
true
);
$elem
.
attr
(
{
html
:
"foo"
},
true
);
equal
(
elem
.
innerHTML
,
"foo"
,
"attr(html)"
);
equal
(
elem
.
innerHTML
,
"foo"
,
"attr(html)"
);
$elem
.
attr
(
{
text
:
"bar"
},
true
);
$elem
.
attr
(
{
text
:
"bar"
},
true
);
equal
(
elem
.
innerHTML
,
"bar"
,
"attr(text)"
);
equal
(
elem
.
innerHTML
,
"bar"
,
"attr(text)"
);
$elem
.
attr
(
{
css
:
{
color
:
"red"
}},
true
);
$elem
.
attr
(
{
css
:
{
color
:
"red"
}
},
true
);
ok
(
/^
(
#ff0000|red
)
$/i
.
test
(
elem
.
style
.
color
),
"attr(css)"
);
ok
(
/^
(
#ff0000|red
)
$/i
.
test
(
elem
.
style
.
color
),
"attr(css)"
);
if
(
jQuery
.
fn
.
width
)
{
// Multiple attributes
$elem
.
attr
({
height
:
10
},
true
);
$elem
.
attr
(
attrObj
,
true
);
equal
(
elem
.
style
.
height
,
"10px"
,
"attr(height)"
);
// Multiple attributes
if
(
jQuery
.
fn
.
width
)
{
$elem
.
attr
({
equal
(
elem
.
style
.
width
,
"10px"
,
"attr({width:})"
);
width
:
10
,
css
:{
paddingLeft
:
1
,
paddingRight
:
1
}
},
true
);
equal
(
elem
.
style
.
width
,
"10px"
,
"attr({...})"
);
$elem
.
attr
(
{
height
:
10
},
true
);
}
else
{
equal
(
elem
.
style
.
height
,
"10px"
,
"attr(height)"
);
}
$elem
.
attr
({
if
(
jQuery
.
fn
.
offset
)
{
css
:{
paddingLeft
:
1
,
paddingRight
:
1
}
equal
(
elem
.
style
.
top
,
"1px"
,
"attr({offset:})"
);
},
true
);
ok
(
true
,
"DUMMY: attr(height)"
);
$elem
.
attr
(
{
offset
:
{
top
:
1
,
left
:
1
}
},
true
);
ok
(
true
,
"DUMMY: attr({...}
)"
);
equal
(
elem
.
style
.
left
,
"1px"
,
"attr(offset
)"
);
}
}
equal
(
elem
.
style
.
paddingLeft
,
"1px"
,
"attr({
...})"
);
equal
(
elem
.
style
.
paddingLeft
,
"1px"
,
"attr({
css:})"
);
equal
(
elem
.
style
.
paddingRight
,
"1px"
,
"attr({
...})"
);
equal
(
elem
.
style
.
paddingRight
,
"1px"
,
"attr({
css:})"
);
});
});
test
(
"attr(String, Object) - Loaded via XML document"
,
function
()
{
test
(
"attr(String, Object) - Loaded via XML document"
,
function
()
{
...
...
test/unit/core.js
View file @
c68ab270
...
@@ -18,24 +18,48 @@ test("Basic requirements", function() {
...
@@ -18,24 +18,48 @@ test("Basic requirements", function() {
});
});
test
(
"jQuery()"
,
function
()
{
test
(
"jQuery()"
,
function
()
{
expect
(
29
);
// Basic constructor's behavior
var
elem
,
i
,
obj
=
jQuery
(
"div"
),
main
=
jQuery
(
"#qunit-fixture"
),
code
=
jQuery
(
"<code/>"
),
img
=
jQuery
(
"<img/>"
),
div
=
jQuery
(
"<div/><hr/><code/><b/>"
),
exec
=
false
,
long
=
""
,
expected
=
28
,
attrObj
=
{
css
:
{
paddingLeft
:
1
,
paddingRight
:
1
},
click
:
function
()
{
ok
(
exec
,
"Click executed."
);
},
text
:
"test"
,
"class"
:
"test2"
,
id
:
"test3"
};
if
(
jQuery
.
fn
.
width
)
{
expected
++
;
attrObj
.
width
=
10
;
}
if
(
jQuery
.
fn
.
offset
)
{
expected
++
;
attrObj
.
offset
=
{
top
:
1
,
left
:
1
};
}
expect
(
expected
);
// Basic constructor's behavior
equal
(
jQuery
().
length
,
0
,
"jQuery() === jQuery([])"
);
equal
(
jQuery
().
length
,
0
,
"jQuery() === jQuery([])"
);
equal
(
jQuery
(
undefined
).
length
,
0
,
"jQuery(undefined) === jQuery([])"
);
equal
(
jQuery
(
undefined
).
length
,
0
,
"jQuery(undefined) === jQuery([])"
);
equal
(
jQuery
(
null
).
length
,
0
,
"jQuery(null) === jQuery([])"
);
equal
(
jQuery
(
null
).
length
,
0
,
"jQuery(null) === jQuery([])"
);
equal
(
jQuery
(
""
).
length
,
0
,
"jQuery('') === jQuery([])"
);
equal
(
jQuery
(
""
).
length
,
0
,
"jQuery('') === jQuery([])"
);
equal
(
jQuery
(
"#"
).
length
,
0
,
"jQuery('#') === jQuery([])"
);
equal
(
jQuery
(
"#"
).
length
,
0
,
"jQuery('#') === jQuery([])"
);
var
obj
=
jQuery
(
"div"
);
equal
(
jQuery
(
obj
).
selector
,
"div"
,
"jQuery(jQueryObj) == jQueryObj"
);
equal
(
jQuery
(
obj
).
selector
,
"div"
,
"jQuery(jQueryObj) == jQueryObj"
);
// can actually yield more than one, when iframes are included, the window is an array as well
// can actually yield more than one, when iframes are included, the window is an array as well
equal
(
jQuery
(
window
).
length
,
1
,
"Correct number of elements generated for jQuery(window)"
);
equal
(
jQuery
(
window
).
length
,
1
,
"Correct number of elements generated for jQuery(window)"
);
var
main
=
jQuery
(
"#qunit-fixture"
);
deepEqual
(
jQuery
(
"div p"
,
main
).
get
(),
q
(
"sndp"
,
"en"
,
"sap"
),
"Basic selector with jQuery object as context"
);
deepEqual
(
jQuery
(
"div p"
,
main
).
get
(),
q
(
"sndp"
,
"en"
,
"sap"
),
"Basic selector with jQuery object as context"
);
/*
/*
...
@@ -56,13 +80,12 @@ test("jQuery()", function() {
...
@@ -56,13 +80,12 @@ test("jQuery()", function() {
}
}
ok( pass, "jQuery('<tag>') needs optional document parameter to ease cross-frame DOM wrangling, see #968" );*/
ok( pass, "jQuery('<tag>') needs optional document parameter to ease cross-frame DOM wrangling, see #968" );*/
var
code
=
jQuery
(
"<code/>"
);
equal
(
code
.
length
,
1
,
"Correct number of elements generated for code"
);
equal
(
code
.
length
,
1
,
"Correct number of elements generated for code"
);
equal
(
code
.
parent
().
length
,
0
,
"Make sure that the generated HTML has no parent."
);
equal
(
code
.
parent
().
length
,
0
,
"Make sure that the generated HTML has no parent."
);
var
img
=
jQuery
(
"<img/>"
);
equal
(
img
.
length
,
1
,
"Correct number of elements generated for img"
);
equal
(
img
.
length
,
1
,
"Correct number of elements generated for img"
);
equal
(
img
.
parent
().
length
,
0
,
"Make sure that the generated HTML has no parent."
);
equal
(
img
.
parent
().
length
,
0
,
"Make sure that the generated HTML has no parent."
);
var
div
=
jQuery
(
"<div/><hr/><code/><b/>"
);
equal
(
div
.
length
,
4
,
"Correct number of elements generated for div hr code b"
);
equal
(
div
.
length
,
4
,
"Correct number of elements generated for div hr code b"
);
equal
(
div
.
parent
().
length
,
0
,
"Make sure that the generated HTML has no parent."
);
equal
(
div
.
parent
().
length
,
0
,
"Make sure that the generated HTML has no parent."
);
...
@@ -70,30 +93,14 @@ test("jQuery()", function() {
...
@@ -70,30 +93,14 @@ test("jQuery()", function() {
equal
(
jQuery
(
document
.
body
).
get
(
0
),
jQuery
(
"body"
).
get
(
0
),
"Test passing an html node to the factory"
);
equal
(
jQuery
(
document
.
body
).
get
(
0
),
jQuery
(
"body"
).
get
(
0
),
"Test passing an html node to the factory"
);
var
exec
=
false
,
elem
=
jQuery
(
"<div/>"
,
attrObj
);
elem
;
if
(
jQuery
.
fn
.
width
)
{
if
(
jQuery
.
fn
.
width
)
{
elem
=
jQuery
(
"<div/>"
,
{
width
:
10
,
css
:
{
paddingLeft
:
1
,
paddingRight
:
1
},
click
:
function
(){
ok
(
exec
,
"Click executed."
);
},
text
:
"test"
,
"class"
:
"test2"
,
id
:
"test3"
});
equal
(
elem
[
0
].
style
.
width
,
"10px"
,
"jQuery() quick setter width"
);
equal
(
elem
[
0
].
style
.
width
,
"10px"
,
"jQuery() quick setter width"
);
}
else
{
}
elem
=
jQuery
(
"<div/>"
,
{
css
:
{
paddingLeft
:
1
,
paddingRight
:
1
},
click
:
function
(){
ok
(
exec
,
"Click executed."
);
},
text
:
"test"
,
"class"
:
"test2"
,
id
:
"test3"
});
ok
(
true
,
"DUMMY: jQuery() quick setter width"
);
if
(
jQuery
.
fn
.
offset
)
{
equal
(
elem
[
0
].
style
.
top
,
"1px"
,
"jQuery() quick setter offset"
);
}
}
equal
(
elem
[
0
].
style
.
paddingLeft
,
"1px"
,
"jQuery quick setter css"
);
equal
(
elem
[
0
].
style
.
paddingLeft
,
"1px"
,
"jQuery quick setter css"
);
...
@@ -109,7 +116,7 @@ test("jQuery()", function() {
...
@@ -109,7 +116,7 @@ test("jQuery()", function() {
// manually clean up detached elements
// manually clean up detached elements
elem
.
remove
();
elem
.
remove
();
for
(
var
i
=
0
;
i
<
3
;
++
i
)
{
for
(
i
=
0
;
i
<
3
;
++
i
)
{
elem
=
jQuery
(
"<input type='text' value='TEST' />"
);
elem
=
jQuery
(
"<input type='text' value='TEST' />"
);
}
}
equal
(
elem
[
0
].
defaultValue
,
"TEST"
,
"Ensure cached nodes are cloned properly (Bug #6655)"
);
equal
(
elem
[
0
].
defaultValue
,
"TEST"
,
"Ensure cached nodes are cloned properly (Bug #6655)"
);
...
@@ -120,8 +127,7 @@ test("jQuery()", function() {
...
@@ -120,8 +127,7 @@ test("jQuery()", function() {
equal
(
jQuery
(
" <div/> "
).
length
,
1
,
"Make sure whitespace is trimmed."
);
equal
(
jQuery
(
" <div/> "
).
length
,
1
,
"Make sure whitespace is trimmed."
);
equal
(
jQuery
(
" a<div/>b "
).
length
,
1
,
"Make sure whitespace and other characters are trimmed."
);
equal
(
jQuery
(
" a<div/>b "
).
length
,
1
,
"Make sure whitespace and other characters are trimmed."
);
var
long
=
""
;
for
(
i
=
0
;
i
<
128
;
i
++
)
{
for
(
var
i
=
0
;
i
<
128
;
i
++
)
{
long
+=
"12345678"
;
long
+=
"12345678"
;
}
}
...
...
test/unit/offset.js
View file @
c68ab270
if
(
jQuery
.
fn
.
offset
)
{
module
(
"offset"
,
{
teardown
:
moduleTeardown
});
module
(
"offset"
,
{
teardown
:
moduleTeardown
});
test
(
"disconnected node"
,
function
()
{
test
(
"disconnected node"
,
function
()
{
...
@@ -475,3 +477,5 @@ test("fractions (see #7730 and #7885)", function() {
...
@@ -475,3 +477,5 @@ test("fractions (see #7730 and #7885)", function() {
div
.
remove
();
div
.
remove
();
});
});
}
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