Fix up the unit tests. Polyline.closestLayerPoint and noConflict were broken.
This commit is contained in:
parent
0479e24034
commit
61ce465134
@ -1,15 +1,14 @@
|
||||
describe('L#noConflict', function() {
|
||||
it('should restore the previous L value and return Leaflet namespace', function(){
|
||||
|
||||
expect(L.VERSION).toBeDefined();
|
||||
expect(L.version).toBeDefined();
|
||||
|
||||
var L2 = L.noConflict();
|
||||
|
||||
expect(L).toEqual('test');
|
||||
expect(L2.VERSION).toBeDefined();
|
||||
|
||||
this.after(function() {
|
||||
this.after(function () {
|
||||
window.L = L2;
|
||||
});
|
||||
|
||||
expect(L).toEqual('test');
|
||||
expect(L2.version).toBeDefined();
|
||||
});
|
||||
});
|
@ -3,13 +3,14 @@ var L, originalL;
|
||||
if (typeof exports !== 'undefined') {
|
||||
L = exports;
|
||||
} else {
|
||||
L = {};
|
||||
|
||||
|
||||
originalL = window.L;
|
||||
L = {};
|
||||
|
||||
L.noConflict = function () {
|
||||
var l = window.L;
|
||||
window.L = originalL;
|
||||
return L;
|
||||
return l;
|
||||
};
|
||||
|
||||
window.L = L;
|
||||
|
@ -63,10 +63,10 @@ L.Polyline = L.Path.extend({
|
||||
for (var i = 1, len = points.length; i < len; i++) {
|
||||
p1 = points[i - 1];
|
||||
p2 = points[i];
|
||||
var point = L.LineUtil._sqClosestPointOnSegment(p, p1, p2);
|
||||
if (point._sqDist < minDistance) {
|
||||
minDistance = point._sqDist;
|
||||
minPoint = point;
|
||||
var sqDist = L.LineUtil._sqClosestPointOnSegment(p, p1, p2, true);
|
||||
if (sqDist < minDistance) {
|
||||
minDistance = sqDist;
|
||||
minPoint = L.LineUtil._sqClosestPointOnSegment(p, p1, p2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user