From 8b1d17fe0ef65319e55c61b9ee5035dd298a83a3 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Wed, 1 Aug 2018 10:16:38 +0200 Subject: [PATCH] [FIX] base: also add vendor prefixes with debug=assets As explained here: https://github.com/odoo/odoo/commit/770aec399c4e6e29cfc5854318cbda19a605315d#diff-3d7991d8bc534e0372f0bd9b4f9165a7R424, we have to post-process the generated css to add some vendor prefixes. Doing that there was however only adding those in non-debug=assets files. --- odoo/addons/base/models/assetsbundle.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/odoo/addons/base/models/assetsbundle.py b/odoo/addons/base/models/assetsbundle.py index 002d8ad2d45..d60cfe34753 100644 --- a/odoo/addons/base/models/assetsbundle.py +++ b/odoo/addons/base/models/assetsbundle.py @@ -419,16 +419,7 @@ class AssetsBundle(object): except psycopg2.Error: pass - css_content = '\n'.join(asset.minify() for asset in self.stylesheets) - - # Post process the produced css to add required vendor prefixes here - css_content = re.sub(r'(appearance: (\w+);)', r'-webkit-appearance: \2; -moz-appearance: \2; \1', css_content); - - css_content = re.sub(r'(display: ((?:inline-)?)flex((?: ?!important)?);)', r'display: -webkit-\2flex\3; \1', css_content) # For PhantomJS tests - css_content = re.sub(r'(flex-flow: (\w+ \w+);)', r'-webkit-flex-flow: \2; \1', css_content) # For PhantomJS tests - css_content = re.sub(r'(flex: (\d+ \d+ (?:\d+|auto));)', r'-webkit-flex: \2; \1', css_content) # For PhantomJS tests - - return css_content + return '\n'.join(asset.minify() for asset in self.stylesheets) def compile_css(self, compiler, source): """Sanitizes @import rules, remove duplicates @import rules, then compile""" @@ -450,12 +441,23 @@ class AssetsBundle(object): return '' source = re.sub(self.rx_preprocess_imports, sanitize, source) + compiled = '' try: compiled = compiler(source) - return compiled.strip() except CompileError as e: return handle_compile_error(e, source=source) + compiled = compiled.strip() + + # Post process the produced css to add required vendor prefixes here + compiled = re.sub(r'(appearance: (\w+);)', r'-webkit-appearance: \2; -moz-appearance: \2; \1', compiled); + + compiled = re.sub(r'(display: ((?:inline-)?)flex((?: ?!important)?);)', r'display: -webkit-\2flex\3; \1', compiled) # For PhantomJS tests + compiled = re.sub(r'(flex-flow: (\w+ \w+);)', r'-webkit-flex-flow: \2; \1', compiled) # For PhantomJS tests + compiled = re.sub(r'(flex: (\d+ \d+ (?:\d+|auto));)', r'-webkit-flex: \2; \1', compiled) # For PhantomJS tests + + return compiled + def get_preprocessor_error(self, stderr, source=None): """Improve and remove sensitive information from sass/less compilator error messages""" error = misc.ustr(stderr).split('Load paths')[0].replace(' Use --trace for backtrace.', '')