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
faefbb1a
Commit
faefbb1a
authored
Dec 19, 2010
by
Colin Snover
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #7717 and #7165. Thanks to dmethvin and iliakan for their help fixing these issues.
parent
291b1edf
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
10 deletions
+30
-10
data.js
src/data.js
+6
-2
manipulation.js
src/manipulation.js
+2
-2
manipulation.js
test/unit/manipulation.js
+22
-6
No files found.
src/data.js
View file @
faefbb1a
...
@@ -21,6 +21,10 @@ jQuery.extend({
...
@@ -21,6 +21,10 @@ jQuery.extend({
"applet"
:
true
"applet"
:
true
},
},
hasData
:
function
(
elem
)
{
return
!
elem
.
nodeType
||
(
elem
[
jQuery
.
expando
]
&&
!
jQuery
.
isEmptyObject
(
jQuery
.
cache
[
elem
[
jQuery
.
expando
]
]));
},
data
:
function
(
elem
,
name
,
data
)
{
data
:
function
(
elem
,
name
,
data
)
{
if
(
!
jQuery
.
acceptData
(
elem
)
)
{
if
(
!
jQuery
.
acceptData
(
elem
)
)
{
return
;
return
;
...
...
src/manipulation.js
View file @
faefbb1a
...
@@ -373,12 +373,12 @@ function cloneCopyEvent(orig, ret) {
...
@@ -373,12 +373,12 @@ function cloneCopyEvent(orig, ret) {
var
i
=
0
;
var
i
=
0
;
ret
.
each
(
function
()
{
ret
.
each
(
function
()
{
if
(
this
.
nodeType
!==
1
||
this
.
nodeName
!==
(
orig
[
i
]
&&
orig
[
i
].
nodeName
)
)
{
if
(
this
.
nodeType
!==
1
||
this
.
nodeName
!==
(
orig
[
i
]
&&
orig
[
i
].
nodeName
)
||
!
jQuery
.
hasData
(
orig
[
i
])
)
{
return
;
return
;
}
}
var
oldData
=
jQuery
.
data
(
orig
[
i
++
]
),
var
oldData
=
jQuery
.
data
(
orig
[
i
++
]
),
curData
=
jQuery
.
data
(
this
,
oldData
),
curData
=
jQuery
.
data
(
this
,
jQuery
.
extend
(
true
,
{},
oldData
)
),
events
=
oldData
&&
oldData
.
events
;
events
=
oldData
&&
oldData
.
events
;
if
(
events
)
{
if
(
events
)
{
...
...
test/unit/manipulation.js
View file @
faefbb1a
...
@@ -51,7 +51,7 @@ test("text(Function) with incoming value", function() {
...
@@ -51,7 +51,7 @@ test("text(Function) with incoming value", function() {
});
});
var
testWrap
=
function
(
val
)
{
var
testWrap
=
function
(
val
)
{
expect
(
1
8
);
expect
(
1
9
);
var
defaultText
=
'Try them out:'
var
defaultText
=
'Try them out:'
var
result
=
jQuery
(
'#first'
).
wrap
(
val
(
'<div class="red"><span></span></div>'
)).
text
();
var
result
=
jQuery
(
'#first'
).
wrap
(
val
(
'<div class="red"><span></span></div>'
)).
text
();
equals
(
defaultText
,
result
,
'Check for wrapping of on-the-fly html'
);
equals
(
defaultText
,
result
,
'Check for wrapping of on-the-fly html'
);
...
@@ -80,10 +80,20 @@ var testWrap = function(val) {
...
@@ -80,10 +80,20 @@ var testWrap = function(val) {
equals
(
jQuery
(
"#nonnodes > i"
).
text
(),
j
.
text
(),
"Check node,textnode,comment wraps doesn't hurt text"
);
equals
(
jQuery
(
"#nonnodes > i"
).
text
(),
j
.
text
(),
"Check node,textnode,comment wraps doesn't hurt text"
);
// Try wrapping a disconnected node
// Try wrapping a disconnected node
var
cacheLength
=
0
;
for
(
var
i
in
jQuery
.
cache
)
{
cacheLength
++
;
}
j
=
jQuery
(
"<label/>"
).
wrap
(
val
(
"<li/>"
));
j
=
jQuery
(
"<label/>"
).
wrap
(
val
(
"<li/>"
));
equals
(
j
[
0
].
nodeName
.
toUpperCase
(),
"LABEL"
,
"Element is a label"
);
equals
(
j
[
0
].
nodeName
.
toUpperCase
(),
"LABEL"
,
"Element is a label"
);
equals
(
j
[
0
].
parentNode
.
nodeName
.
toUpperCase
(),
"LI"
,
"Element has been wrapped"
);
equals
(
j
[
0
].
parentNode
.
nodeName
.
toUpperCase
(),
"LI"
,
"Element has been wrapped"
);
for
(
i
in
jQuery
.
cache
)
{
cacheLength
--
;
}
equals
(
cacheLength
,
0
,
"No memory leak in jQuery.cache (bug #7165)"
);
// Wrap an element containing a text node
// Wrap an element containing a text node
j
=
jQuery
(
"<span/>"
).
wrap
(
"<div>test</div>"
);
j
=
jQuery
(
"<span/>"
).
wrap
(
"<div>test</div>"
);
equals
(
j
[
0
].
previousSibling
.
nodeType
,
3
,
"Make sure the previous node is a text element"
);
equals
(
j
[
0
].
previousSibling
.
nodeType
,
3
,
"Make sure the previous node is a text element"
);
...
@@ -856,7 +866,7 @@ test("replaceAll(String|Element|Array<Element>|jQuery)", function() {
...
@@ -856,7 +866,7 @@ test("replaceAll(String|Element|Array<Element>|jQuery)", function() {
});
});
test
(
"clone()"
,
function
()
{
test
(
"clone()"
,
function
()
{
expect
(
3
6
);
expect
(
3
7
);
equals
(
'This is a normal link: Yahoo'
,
jQuery
(
'#en'
).
text
(),
'Assert text for #en'
);
equals
(
'This is a normal link: Yahoo'
,
jQuery
(
'#en'
).
text
(),
'Assert text for #en'
);
var
clone
=
jQuery
(
'#yahoo'
).
clone
();
var
clone
=
jQuery
(
'#yahoo'
).
clone
();
equals
(
'Try them out:Yahoo'
,
jQuery
(
'#first'
).
append
(
clone
).
text
(),
'Check for clone'
);
equals
(
'Try them out:Yahoo'
,
jQuery
(
'#first'
).
append
(
clone
).
text
(),
'Check for clone'
);
...
@@ -914,10 +924,16 @@ test("clone()", function() {
...
@@ -914,10 +924,16 @@ test("clone()", function() {
equals
(
clone
.
html
(),
div
.
html
(),
"Element contents cloned"
);
equals
(
clone
.
html
(),
div
.
html
(),
"Element contents cloned"
);
equals
(
clone
[
0
].
nodeName
.
toUpperCase
(),
"DIV"
,
"DIV element cloned"
);
equals
(
clone
[
0
].
nodeName
.
toUpperCase
(),
"DIV"
,
"DIV element cloned"
);
div
=
jQuery
(
"<div/>"
).
data
({
a
:
true
,
b
:
true
});
div
=
jQuery
(
"<div/>"
).
data
({
div
=
div
.
clone
(
true
);
a
:
true
,
b
:
true
,
equals
(
div
.
data
(
"a"
),
true
,
"Data cloned."
);
c
:
{
nesty
:
[
"Block"
,
"Head"
]
}
equals
(
div
.
data
(
"b"
),
true
,
"Data cloned."
);
});
var
div2
=
div
.
clone
(
true
);
equals
(
div2
.
data
(
"a"
),
true
,
"Data cloned."
);
equals
(
div2
.
data
(
"b"
),
true
,
"Data cloned."
);
var
c
=
div2
.
data
(
"c"
);
c
.
nesty
[
0
]
=
"Fish"
;
equals
(
div
.
data
(
"c"
).
nesty
[
0
],
"Block"
,
"Ensure cloned element data is deep copied (Bug #7717)"
);
var
form
=
document
.
createElement
(
"form"
);
var
form
=
document
.
createElement
(
"form"
);
form
.
action
=
"/test/"
;
form
.
action
=
"/test/"
;
...
...
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