-
Notifications
You must be signed in to change notification settings - Fork 424
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
perf: skip reapplying empty html when target is already empty #932
Conversation
- when calling `applyHtmlCode()` method and our target element is empty and we try to reapply empty, it should always be ok to simply skip this reassignment. - this should also help with performance since trying to reapply empty using `innerHTML` will probably cause a canvas repaint but if we manage to skip this then a repaint will also be skipped - this should also help with CSP because we could write a Formatter with native element while still returning empty string when there's no value to return, that will then call `applyHtmlCode` and skip the assignment if the cell is already empty
@JesperJakobsenCIM did you manage to be fully CSP compliant in your application? I'm still working on my end in my other Slickgrid-Universal project, and I saw that this PR could help a bit with CSP when creating a Formatter with native element but return empty string when there is no value to display in the cell formatter. With this PR it will do 2 things:
Anyway I was just curious to know if managed to be fully CSP compliant in your project? I'm assuming EDIT Taking another look at the unsafe-inline for the style and I guess we'll have a few non-compliance since dynamically changing |
Sadly haven't gotten by to be fully CSP compliant yet, however the minor testing i have done looks promising so far. I'm expecting to properly do it over the Christmas, since we have quite a bit of maintenance work in that period with package updating too. |
@JesperJakobsenCIM I found another dynamic function creation that is not CSP safe, do you think you can work your magic and provide a duplicate function that is CSP safe? That dynamic function is used with Grouping/DraggableGrouping SlickGrid/src/slick.dataview.ts Lines 1024 to 1041 in b1b4fa2
|
I can look into it |
applyHtmlCode()
method and our target element is empty and we try to reapply empty, it should always be ok to simply skip this reassignment because the end result is exactly the sameinnerHTML
will probably cause a canvas repaint but if we manage to skip this assignment then a repaint will also be skippedapplyHtmlCode
and skip the assignment if the cell is already emptyfor example the code below would be 100% CSP Safe and iinterpreted by SlickGrid as native without using
innerHTML
at all