openui5 icon indicating copy to clipboard operation
openui5 copied to clipboard

Replace jQuery $().toggleClass by vanilla js classList.toggle in sap.f library

Open mauriciolauffer opened this issue 3 years ago • 3 comments
trafficstars

Just replacing jQuery .toggleClass by vanilla js classList.toggle in sap.f library. Hopefully more people can help tackling other libraries, then other jQuery features, until we don't have jQuery in the code base anymore.

jQuery .toggleClass can be replaced by classList.toggle and it's supported by IE11, not just modern browsers.

sap.f.DynamicPageTitle still have 2 references to .toggleClass due to method ._setContentAreaFlexBasis using parameter $node, it's not locally defined.

https://github.com/mauriciolauffer/openui5/blob/6d0303f509537763dd321a3d4f48a10be23bf998/src/sap.f/src/sap/f/DynamicPageTitle.js#L1441 https://github.com/mauriciolauffer/openui5/blob/6d0303f509537763dd321a3d4f48a10be23bf998/src/sap.f/src/sap/f/DynamicPageTitle.js#L1445

mauriciolauffer avatar Jan 28 '22 07:01 mauriciolauffer

CLA assistant check
All committers have signed the CLA.

cla-assistant[bot] avatar Feb 06 '22 03:02 cla-assistant[bot]

@mauriciolauffer Thanks for this PR. I have created an internal incident DINC0034895 to follow-up on this. The responsible team will get in touch with you.

flovogt avatar Jan 09 '24 12:01 flovogt

Hello @mauriciolauffer , Thank you for your pull request.

It seems it's been a while, since the pull request has been opened. As it is outdated, the change needs to be rebased with the master branch.

What is more, we would like to ask you for some rework. Accessing the DOM too frequently or unnecessarily (each time we are searching for an element), triggers a reflow or repaint, which are expensive operations. We are trying to minimize accessing the DOM, whenever possible, in order to keep a good performance. As you have probably noticed, Dynamic page, for example, has _cacheDomElements function (called after rerendering), which caches most of the DOM references, so we do not need to search for them all the time. We would like to keep it like this and work as much as possible with cached DOM references. That's why, in order this pull request to be merged, additional changes must be done - wherever jQuery methods are used on the saved DOM references (not jQuery objects), they need to be replaced with vanilla JavaScript.

Regards, Iliana

IlianaB avatar Feb 01 '24 13:02 IlianaB

After a short conversation with @IlianaB we have decided to close this PR since, there is no response from the author for more than 4 weeks.

viktorsperling avatar Apr 04 '24 12:04 viktorsperling

"Accessing the DOM too frequently or unnecessarily (each time we are searching for an element), triggers a reflow or repaint, which are expensive operations." That's incorrect. Reading the DOM doesn't trigger reflow/repaint. Updating the DOM does.

mauriciolauffer avatar Apr 05 '24 05:04 mauriciolauffer