aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-10-13 16:43:26 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-10-13 16:44:13 -0400
commitc92fc11fcdad294059931a0927ec7f7701eb5be5 (patch)
tree99d87a8e1dea187300e15863b0bd49d3e35dc1fd /ext/fg/js
parent4f8c84d524365a32e6f4478597905bc553ad20c2 (diff)
Fix getElementWritingMode returning deprecated values on Edge
Diffstat (limited to 'ext/fg/js')
-rw-r--r--ext/fg/js/source.js26
1 files changed, 21 insertions, 5 deletions
diff --git a/ext/fg/js/source.js b/ext/fg/js/source.js
index ee4f58e2..a483952e 100644
--- a/ext/fg/js/source.js
+++ b/ext/fg/js/source.js
@@ -229,13 +229,29 @@ class TextSourceRange {
}
static getElementWritingMode(element) {
- if (element === null) {
- return 'horizontal-tb';
+ if (element !== null) {
+ const style = window.getComputedStyle(element);
+ const writingMode = style.writingMode;
+ if (typeof writingMode === 'string') {
+ TextSourceRange.normalizeWritingMode(writingMode);
+ }
}
+ return 'horizontal-tb';
+ }
- const style = window.getComputedStyle(element);
- const writingMode = style.writingMode;
- return typeof writingMode === 'string' ? writingMode : 'horizontal-tb';
+ static normalizeWritingMode(writingMode) {
+ switch (writingMode) {
+ case 'lr':
+ case 'lr-tb':
+ case 'rl':
+ return 'horizontal-tb';
+ case 'tb':
+ return 'vertical-lr';
+ case 'tb-rl':
+ return 'vertical-rl';
+ default:
+ return writingMode;
+ }
}
static getNodesInRange(range) {