uploadcare-widget
uploadcare-widget copied to clipboard
add support for removing styles and stylesheet urls to CssCollector
Description
Styling with uploadcare.tabsCss.addUrl()
and uploadcare.tabsCss.addStyle()
would benefit from the ability to also have methods for removeUrl()
and removeStyle()
. This pr adds those capabilities.
The issue I came across without remove methods may never be seen in a production release, but when testing how custom iframe styling looks with a light theme and dark theme, I realized that stylesheet urls can't be toggled, so it gets stuck.
Also, there is nothing keeping the same style tag added to the iframe repeatedly, so in testing I am seeing a new style added every time I toggle the theme. Again, probably only something that would be noticed in production, but easy enough to fix.
n/a
- add
removeStyle()
andremoveUrl()
methods to CssCollector. (usingarray.filter()
) - utilize
array.includes()
instead ofarray.indexOf()
for checking membership-
array.includes
is supported in all modern environments and is more descriptive of what is actually being checked for - I realize that
array.indexOf(item) >= 0
is used in many other places, but that's not why I'm making this PR. I just figured I would include this small update to this action only.
-
- add
array.indexOf()
check toaddStyle()
to prevent the same style tag from being duplicated
Checklist
- [x] Tests (if applicable)
- [ ] Documentation (if applicable)
- [ ] Changelog stub (or use conventional commit messages)
This pull request introduces 1 alert when merging d95c1103f6834220279ad32af90f6140a92be5b7 into 98807d197a2ad81c70c7f3b4719dfd9f0a0106a9 - view on LGTM.com
new alerts:
- 1 for Unused variable, import, function or class
Hey @rnwelsh, thanks for the contributing!
Unfortunately, using Array.includes
can break backward compatibility for some of our customers whose users use IE10+, which support we claim. Therefore, it's still better to use an old school Array.indexOf
.