Fix for potential issues with getInheritedTheme#2778
Fix for potential issues with getInheritedTheme#2778ronchalant wants to merge 4 commits intojquery-archive:masterfrom
Conversation
js/jquery.mobile.core.js
Outdated
There was a problem hiding this comment.
Thanks for pointing out the possibility for a false positive, the original code didn't have the \b in it so I added that when I was trying to get rid of all the duplicate code. This function gets called quite a bit, especially since it is used in buttonMarkup. I would prefer if it wasn't recursive so we don't have to incur the recursive function call costs. It might be better to simply call parents() and loop manually over the resulting list.
|
I committed another change to utilize parents() using the selector from the original couple with a regex check in an each() block. In a quick test getting the inheritedTheme of a button 10,000 times with each approach the results were virtually identical, around 900ms. I did find that my check to stop infinite recursion was bad; I needed p.parent().length in the check not p.parent() by itself. |
|
We appreciate the update, but since the associated issue has been closed I'm going to do the same here. In general we're going to try to avoid adding functions to Further commentary is welcome. |
per: #2770
I think the safest approach is to turn this into a recursive function. Normally I'd reuse closest(), but unless we put in a jQuery expr to support our regex (which seems a bit much for this) this seems the best approach.
It also allows you to get an inherited theme right from a jQuery object, i.e. $("#field-one").inheritedTheme()