No-op bringToFront/Back when Path is not on a map (fixes #2439)

This commit is contained in:
John Firebaugh 2014-11-05 15:13:28 -08:00
parent 40376dc3be
commit ea2c397523
3 changed files with 22 additions and 2 deletions

View File

@ -71,6 +71,7 @@
<!-- /layer/vector/ -->
<script type="text/javascript" src="suites/layer/vector/CircleSpec.js"></script>
<script type="text/javascript" src="suites/layer/vector/CircleMarkerSpec.js"></script>
<script type="text/javascript" src="suites/layer/vector/PathSpec.js"></script>
<script type="text/javascript" src="suites/layer/vector/PolygonSpec.js"></script>
<script type="text/javascript" src="suites/layer/vector/PolylineSpec.js"></script>
<script type="text/javascript" src="suites/layer/vector/PolylineGeometrySpec.js"></script>

View File

@ -0,0 +1,15 @@
describe('Path', function () {
describe('#bringToBack', function () {
it('is a no-op for layers not on a map', function () {
var path = new L.Path();
expect(path.bringToBack()).to.equal(path);
});
});
describe('#bringToFront', function () {
it('is a no-op for layers not on a map', function () {
var path = new L.Path();
expect(path.bringToFront()).to.equal(path);
});
})
});

View File

@ -61,12 +61,16 @@ L.Path = L.Layer.extend({
},
bringToFront: function () {
this._renderer._bringToFront(this);
if (this._renderer) {
this._renderer._bringToFront(this);
}
return this;
},
bringToBack: function () {
this._renderer._bringToBack(this);
if (this._renderer) {
this._renderer._bringToBack(this);
}
return this;
},