Inline styles are inherently bad for accessibility, mobile friendliness, and security.
Instead of a series of hacks to try to get around this, with an endless number of subsequent issues, instead let's just stop allowing them.
Note: For Wikimedia production, the TemplateStyles extension would replace the need for inline styles for all templates. This ticket is very far away from implementation, and will not be done before migration of uses to something that retains the abilities for wikis to do this. There is no need to panic. :-)