Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve replaceWith #1038

Closed
wants to merge 1 commit into from
Closed

Improve replaceWith #1038

wants to merge 1 commit into from

Conversation

markelog
Copy link
Member

It's faster, smaller (-10 bytes) and simpler.

val = !isFunc ? value : value.call( this, i, this );

if ( isDisconnected( this ) ) {
// for disconnected elements, we replace with the new content in the set. We use
// clone here to ensure that each replaced instance is unique
self[ i ] = jQuery( val ).clone()[ 0 ];
return;
return self[ i ] = jQuery( val ).clone()[ 0 ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this changed behaviour? There are no tests that support a newly appointed return value...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This behaviour isn't changed, look closely

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh. Github's diff doesn't show enough lines to give context to the change. Sorry for the noise.

@gibson042
Copy link
Member

I like your implementation of .replaceWith much better than what's in master, however @PaulBRamos is actively working on this code in order to resolve #4087 for 1.9. I recommend either collaborating with him or waiting until a bugfix commit lands before optimizing here.

@dmethvin
Copy link
Member

Since @PaulBRamos had a patch in this area, I'm going to close this request. @Orkel can you review that code when it arrives?

@dmethvin dmethvin closed this Nov 23, 2012
@markelog
Copy link
Member Author

@dmethvin

@PaulBRamos pull, currently, not replacing this pull, but one is affecting the other.

@dmethvin, @PaulBRamos, @gibson042 I suggest to wait untill fix for #4087 will be landed (i hope it will), but remove from 1033 pull fix for replaceWith/replaceAll and deal with #4087 bug for these methods here, because this change will no longer be needed, with this optimization, howerer, in order to fix #4087 for replaceWith/replaceAll methods i would need @PaulBRamos changes in jQuery.buildFragment.

@PaulBRamos who you feel about that?

@dmethvin can i reopen this pull after @PaulBRamos fix will be landed?

@lock lock bot locked as resolved and limited conversation to collaborators Jan 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants