Side navigation
#5798 closed bug (fixed)
Opened January 14, 2010 02:02AM UTC
Closed January 26, 2010 12:23AM UTC
replaceWith(function) scope is broken
Reported by: | ajpiano | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 1.4.1 |
Component: | core | Version: | 1.4 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
The context of the callback function is not right when you use replaceWith(function);
$("h3").replaceWith(function(i) {
console.log(this);
//'this' will be the next sibling or the parent
});
Because replaceWith(function) ends up delegating to
jQuery(next).before(value)
or
jQuery(parent).append(value)
Since the current element isn't passed in as an argument or
set as the context, there's presently no way to work with it in the callback. I tend to think that the current elem should be set as context, as well as passed in as an arg, to be consistent with .html(function), .text(function), etc.
Attachments (0)
Change History (1)
Changed January 26, 2010 12:23AM UTC by comment:1
component: | unfilled → core |
---|---|
resolution: | → fixed |
status: | new → closed |
Fixed.
http://github.com/jquery/jquery/commit/0b3165fd23ba4d240dd72f93d315bb5f7bf970e8