Skip to content

Only run triggerHandler( "remove" ) for widgets #1182

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

Closed
wants to merge 1 commit into from
Closed

Only run triggerHandler( "remove" ) for widgets #1182

wants to merge 1 commit into from

Conversation

amakhrov
Copy link

ui.widget overrides the $.cleanData method to also call .triggerHandler( "remove" ) method. According to Chrome's profiler, triggerHandler is a relatively slow method.

When element is being removed with $(elem).remove(), $.cleanData is called for each descendant element - and there can be thousands of those elements!

This is an attempt to only execute triggerHandler( "remove" ) for elements that are jQueryUI Widgets and skip that for all other elements.

@scottgonzalez
Copy link
Member

That won't work. Not all widget elements have that class.

@amakhrov
Copy link
Author

However, if you still feel that this part needs some optimizing, another approach can be implemented - say, $.Widget will assign a certain property directly to DOM element. It will ensure that that all widgets have that defined.

I'm just not sure what would be a more idiomatic approach for this in jQueryUI

@scottgonzalez
Copy link
Member

Feel free to come up with alternative and provide actual benchmarks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants