Skip to content

Path.VML.js failure when setStyle is called twice and fill/stroke changes from false to true #641

@rclark

Description

@rclark

I ran into this issue dealing with an application where I have GeoJSON polygon features. They are initially styled with a fill color and stroke: false. On the mouseover event, I change the style by

this.on("featureparse", function(e) {
    e.layer.on("mouseover", function(evt) {
        var hoverStyle = L.Util.extend({}, e.layer.originalStyle, { stroke: true, color: "#FFFF00", weight: 3 });
        e.layer.setStyle(hoverStyle);
    });
....

Works fine elsewhere, but in IE8, an error is thrown on Path.VML.js line 76. During the mouseover call to setStyle, options.stroke === true, however stroke = this._stroke = 'undefined', because, I think, during _initStyle this._stroke was not set since the first time I gave the layer a style options.stroke === false.

I think I would run into the same problem if the initial style set fill: false and the hover-style set fill: true.

I got around it with this patch, and I guess I should extend it to include fill as well, but maybe there's a smarter way to take care of it? I don't get any errors this way, but the stroke still isn't rendering correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions