diff --git a/src/dom/DomUtil.js b/src/dom/DomUtil.js index e1d58682..8e0cac65 100644 --- a/src/dom/DomUtil.js +++ b/src/dom/DomUtil.js @@ -56,7 +56,7 @@ L.DomUtil = { //See https://developer.mozilla.org/en-US/docs/DOM/element.scrollLeft // http://www.nczonline.net/blog/2010/08/03/working-with-bidirectional-bidi-text-and-rtl-languages-on-the-web/ - if (L.DomUtil.getStyle(el, 'direction') == "ltr") { + if (L.DomUtil.documentIsLtr()) { left -= el.scrollLeft || 0; } else { left -= (el.scrollLeft || 0) - el.scrollWidth + el.clientWidth; @@ -68,6 +68,14 @@ L.DomUtil = { return new L.Point(left, top); }, + documentIsLtr: function () { + if (!L.DomUtil._docIsLtrCached) { + L.DomUtil._docIsLtrCached = true; + L.DomUtil._docIsLtr = L.DomUtil.getStyle(document.body, 'direction') == "ltr"; + } + return L.DomUtil._docIsLtr; + }, + create: function (tagName, className, container) { var el = document.createElement(tagName);