2
0
Эх сурвалжийг харах

fix for jquery 3 shitty height problem

Adam Shaw 8 жил өмнө
parent
commit
2841623f68
1 өөрчлөгдсөн 14 нэмэгдсэн , 12 устгасан
  1. 14 12
      tests/lib/jasmine-ext.js

+ 14 - 12
tests/lib/jasmine-ext.js

@@ -206,21 +206,23 @@ beforeEach(function() {
 	}
 
 	function getBounds(node) {
-		var el = $(node);
-		var offset = el.offset();
+		return $(node)[0].getBoundingClientRect();
+	}
 
-		if (!offset) {
-			return false;
-		}
+});
 
-		return {
-			top: offset.top,
-			left: offset.left,
-			right: offset.left + el.outerWidth(),
-			bottom: offset.top + el.outerHeight()
-		};
-	}
+// fix bug with jQuery 3 returning 0 height for <td> elements in the IE's
+[ 'height', 'outerHeight' ].forEach(function(methodName) {
+	var orig = $.fn[methodName];
 
+	$.fn[methodName] = function() {
+		if (!arguments.length && this.is('td')) {
+			return this[0].getBoundingClientRect().height;
+		}
+		else {
+			return orig.apply(this, arguments);
+		}
+	};
 });
 
 // Destroy all calendars afterwards, to prevent memory leaks