]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
test(Modal): reuse _getScrollbarWidth in tests
authorAndrew Luca <thendrluca@gmail.com>
Sun, 21 Oct 2018 10:15:35 +0000 (13:15 +0300)
committerJohann-S <johann.servoire@gmail.com>
Sun, 21 Oct 2018 15:45:02 +0000 (17:45 +0200)
js/tests/unit/modal.js

index 914366ae2214a34fdac8d9d5dbd31399b28439ec..c8f247a3506079bd89aa698f402f1645ba4e9184 100644 (file)
@@ -13,14 +13,7 @@ $(function () {
       // Enable the scrollbar measurer
       $('<style type="text/css"> .modal-scrollbar-measure { position: absolute; top: -9999px; width: 50px; height: 50px; overflow: scroll; } </style>').appendTo('head')
       // Function to calculate the scrollbar width which is then compared to the padding or margin changes
-      $.fn.getScrollbarWidth = function () {
-        var scrollDiv = document.createElement('div')
-        scrollDiv.className = 'modal-scrollbar-measure'
-        document.body.appendChild(scrollDiv)
-        var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
-        document.body.removeChild(scrollDiv)
-        return scrollbarWidth
-      }
+      $.fn.getScrollbarWidth = $.fn.modal.Constructor.prototype._getScrollbarWidth
 
       // Simulate scrollbars
       $('html').css('padding-right', '16px')