Opened 10 years ago
Closed 10 years ago
#12683 closed bug (cantfix)
Unexpected style invalidation in select (performance issue)
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | selector | Version: | 1.8.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
jQuery 1.8.2, Chrome Version 24.0.1284.2 dev, Linux CentOS 6 (haven't checked any other envs)
When executing the find method the style is invalidated due to the setting of an id on the root element.
// our root element var root = $("ul"); // here is where the style is invalidated due to root having an id set root.find(">li");
The find method eventually ends up in the select method which calls context.setAttribute("id", ...) which is the point that the style is invalidated.
This can cause performance problems due to repeated invalidation/revalidation cycles in some applications.
One workaround for the issue is to make sure that the root element has an id.
Change History (3)
comment:1 Changed 10 years ago by
Owner: | set to [email protected]… |
---|---|
Status: | new → pending |
comment:2 Changed 10 years ago by
OK, here is the jsfiddle: http://jsfiddle.net/grvwm/1/
Unfortunately I don't know of a way to check in javascript that a style invalidation/recalculation was done so you will have to look at this information in a profiling tool. I'm using the Timeline tab in Chrome dev tools.
I've included docs of how to check this in the jsfiddle linked above.
comment:3 Changed 10 years ago by
Component: | unfiled → selector |
---|---|
Resolution: | → cantfix |
Status: | pending → closed |
Thank you for creating a test case. I don't think we can fix this because that ID attachment hack is necessary. However, it has been present for a long time so there should be no regression.
Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket.
Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to get started.