summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js/transcoder.js
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-02-14 16:04:23 +0100
committerChristophe Simonis <chs@odoo.com>2018-02-14 16:04:23 +0100
commit9d0de6111471860bc541058be351df4abb8ea167 (patch)
treedda34b2c75ae88141fde4c210a9c2081ab5bfe44 /addons/web_editor/static/src/js/transcoder.js
parent851c29ce0e7f2c53f5ac256f7a232af4c4ad001b (diff)
parent73c2ac451af1afec38d06d102063c81e704ff22b (diff)
[MERGE] forward port branch 10.0 up to 73c2ac451af
Diffstat (limited to 'addons/web_editor/static/src/js/transcoder.js')
-rw-r--r--addons/web_editor/static/src/js/transcoder.js31
1 files changed, 20 insertions, 11 deletions
diff --git a/addons/web_editor/static/src/js/transcoder.js b/addons/web_editor/static/src/js/transcoder.js
index 265ca5ab3f0..a5cf20575d4 100644
--- a/addons/web_editor/static/src/js/transcoder.js
+++ b/addons/web_editor/static/src/js/transcoder.js
@@ -9,17 +9,12 @@ var getMatchedCSSRules = function (a) {
var sheets = document.styleSheets;
for(var i = sheets.length-1; i >= 0 ; i--) {
var rules;
- if (sheets[i].hasOwnProperty('rules')) {
- rules = sheets[i].rules;
- } else {
- //try...catch because Firefox not able to enumerate document.styleSheets[].cssRules[] for cross-domain stylesheets.
- try {
- rules = sheets[i].cssRules;
- } catch(e) {
- console.warn("Can't read the css rules of: " + sheets[i].href, e);
- continue;
- }
- rules = sheets[i].cssRules;
+ // try...catch because browser may not able to enumerate rules for cross-domain sheets
+ try {
+ rules = sheets[i].rules || sheets[i].cssRules;
+ } catch (e) {
+ console.warn("Can't read the css rules of: " + sheets[i].href, e);
+ continue;
}
if (rules) {
for(var r = rules.length-1; r >= 0; r--) {
@@ -131,6 +126,20 @@ var getMatchedCSSRules = function (a) {
delete style['text-decoration-style'];
}
+ // text-align inheritance does not seem to get past <td> elements on some
+ // mail clients
+ if (style['text-align'] === 'inherit') {
+ var $el = $(a).parent();
+ do {
+ var align = $el.css('text-align');
+ if (_.indexOf(['left', 'right', 'center', 'justify'], align) >= 0) {
+ style['text-align'] = align;
+ break;
+ }
+ $el = $el.parent();
+ } while (!$el.is('html'));
+ }
+
return style;
};