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) {
|
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';
|
return 'horizontal-tb';
|
||||||
}
|
}
|
||||||
|
|
||||||
const style = window.getComputedStyle(element);
|
static normalizeWritingMode(writingMode) {
|
||||||
const writingMode = style.writingMode;
|
switch (writingMode) {
|
||||||
return typeof writingMode === 'string' ? writingMode : 'horizontal-tb';
|
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) {
|
static getNodesInRange(range) {
|
||||||
|
Loading…
Reference in New Issue
Block a user