canvas2svg icon indicating copy to clipboard operation
canvas2svg copied to clipboard

Endless loop when copying over defs

Open boeckhoff opened this issue 7 years ago • 0 comments

Hi, I am using the library to render OpenStreetMap data with kothic.js to svg and I encountered this potential endless loop when trying to fill a polygon with an svg as fill image.

code snipped

//copy over defs
while(value.__ctx.__defs.childNodes.length) {
    id = value.__ctx.__defs.childNodes[0].getAttribute("id");
    this.__ids[id] = id;
    this.__defs.appendChild(value.__ctx.__defs.childNodes[0]);
}

I logged the condition of the while loop and it didn't change, therefore resulting in an endless loop. Looking at the code, I cannot see how this would stop in any case, as the childNodes are not removed anywhere.

Am I overlooking something? I fixed the issue for me by changing the code to a for loop, Ill be happy to make a pull request, just thought id check if I am missing something here first.

boeckhoff avatar May 12 '17 09:05 boeckhoff