Fix getElementWritingMode returning deprecated values on Edge
This commit is contained in:
parent
4f8c84d524
commit
c92fc11fcd
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user