-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Replace most remaining Element.setAttribute("style", ...)
usage with Element.style = ...
instead
#11569
Replace most remaining Element.setAttribute("style", ...)
usage with Element.style = ...
instead
#11569
Conversation
…h `Element.style = ...` instead This should hopefully be useful in environments where restrictive CSPs are in effect. In most cases the replacement is entirely straighforward, and there's only a couple of special cases: - For the `src/display/font_loader.js` and `web/pdf_outline_viewer.js `cases, since the elements aren't appended to the document yet, it shouldn't matter if the style properties are set one-by-one rather than all at once. - For the `web/debugger.js` case, there's really no need to set the `padding` inline at all and the definition was simply moved to `web/viewer.css` instead. *Please note:* There's still *a single* case left, in `web/toolbar.js` for setting the width of the zoom dropdown, which is left intact for now. The reasons are that this particular case shouldn't matter for users of the general PDF.js library, and that it'd make a lot more sense to just try and re-factor that very old code anyway (thus fixing the `setAttribute` usage in the process).
/botio-linux preview |
From: Bot.io (Linux m4)ReceivedCommand cmd_preview from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.67.70.0:8877/567834b5676157a/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.67.70.0:8877/567834b5676157a/output.txt Total script time: 1.77 mins Published |
/botio test |
From: Bot.io (Linux m4)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 0 Live output at: http://54.67.70.0:8877/ca6b359979868a9/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 0 Live output at: http://54.215.176.217:8877/787f753c6cb741f/output.txt |
From: Bot.io (Linux m4)FailedFull output at http://54.67.70.0:8877/ca6b359979868a9/output.txt Total script time: 19.60 mins
Image differences available at: http://54.67.70.0:8877/ca6b359979868a9/reftest-analyzer.html#web=eq.log |
From: Bot.io (Windows)FailedFull output at http://54.215.176.217:8877/787f753c6cb741f/output.txt Total script time: 26.78 mins
Image differences available at: http://54.215.176.217:8877/787f753c6cb741f/reftest-analyzer.html#web=eq.log |
Thank you for improving this! It's also more readable in my opinion. |
This should hopefully be useful in environments where restrictive CSPs are in effect.
In most cases the replacement is entirely straighforward, and there's only a couple of special cases:
src/display/font_loader.js
andweb/pdf_outline_viewer.js
cases, since the elements aren't appended to the document yet, it shouldn't matter if the style properties are set one-by-one rather than all at once.web/debugger.js
case, there's really no need to set thepadding
inline at all and the definition was simply moved toweb/viewer.css
instead.Please note: There's still a single case left, in
web/toolbar.js
for setting the width of the zoom dropdown, which is left intact for now.The reasons are that this particular case shouldn't matter for users of the general PDF.js library, and that it'd make a lot more sense to just try and re-factor that very old code anyway (thus fixing the
setAttribute
usage in the process).Fixes #11576