23 lines
486 B
JavaScript
23 lines
486 B
JavaScript
/**
|
|
* placementPolyfill('bottomLeft');
|
|
* output 'bottomStart'
|
|
*/
|
|
function placementPolyfill(placement, rtl) {
|
|
if (rtl === void 0) {
|
|
rtl = false;
|
|
}
|
|
|
|
if (typeof placement === 'string') {
|
|
if (rtl) {
|
|
placement = placement.replace(/left|right/, function (m) {
|
|
return m === 'left' ? 'right' : 'left';
|
|
});
|
|
}
|
|
|
|
return placement.replace(/Left|Top/, 'Start').replace(/Right|Bottom/, 'End');
|
|
}
|
|
|
|
return placement;
|
|
}
|
|
|
|
export default placementPolyfill; |