Fix getElementWritingMode returning deprecated values on Edge

This commit is contained in:
toasted-nutbread 2019-10-13 16:43:26 -04:00
parent 4f8c84d524
commit c92fc11fcd

View File

@ -229,13 +229,29 @@ class TextSourceRange {
}
static getElementWritingMode(element) {
if (element === null) {
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) {