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
0b3165fd
Commit
0b3165fd
authored
Jan 26, 2010
by
jeresig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure that the correct context is being passed in for replaceWith(fn). Fixes #5798.
parent
9f17e70a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
0 deletions
+16
-0
manipulation.js
src/manipulation.js
+6
-0
manipulation.js
test/unit/manipulation.js
+10
-0
No files found.
src/manipulation.js
View file @
0b3165fd
...
@@ -233,6 +233,12 @@ jQuery.fn.extend({
...
@@ -233,6 +233,12 @@ jQuery.fn.extend({
// this can help fix replacing a parent with child elements
// this can help fix replacing a parent with child elements
if
(
!
jQuery
.
isFunction
(
value
)
)
{
if
(
!
jQuery
.
isFunction
(
value
)
)
{
value
=
jQuery
(
value
).
detach
();
value
=
jQuery
(
value
).
detach
();
}
else
{
return
this
.
each
(
function
(
i
)
{
var
self
=
jQuery
(
this
),
old
=
self
.
html
();
self
.
replaceWith
(
value
.
call
(
this
,
i
,
old
)
);
});
}
}
return
this
.
each
(
function
()
{
return
this
.
each
(
function
()
{
...
...
test/unit/manipulation.js
View file @
0b3165fd
...
@@ -720,6 +720,16 @@ test("replaceWith(String|Element|Array<Element>|jQuery)", function() {
...
@@ -720,6 +720,16 @@ test("replaceWith(String|Element|Array<Element>|jQuery)", function() {
test
(
"replaceWith(Function)"
,
function
()
{
test
(
"replaceWith(Function)"
,
function
()
{
testReplaceWith
(
functionReturningObj
);
testReplaceWith
(
functionReturningObj
);
expect
(
16
);
var
y
=
jQuery
(
"#yahoo"
)[
0
];
jQuery
(
y
).
replaceWith
(
function
(){
equals
(
this
,
y
,
"Make sure the context is coming in correctly."
);
});
reset
();
})
})
test
(
"replaceAll(String|Element|Array<Element>|jQuery)"
,
function
()
{
test
(
"replaceAll(String|Element|Array<Element>|jQuery)"
,
function
()
{
...
...
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