svgdotjs / svg.js

The lightweight library for manipulating and animating SVG
https://svgjs.dev
Other
11.07k stars 1.08k forks source link

Fix #1235 #1236

Closed gormster closed 2 years ago

gormster commented 2 years ago

Fixes the bugs in Element.parents() function.

This also introduces a minor change to functionality, but it's a change that previously threw a TypeError, so I don't think it can be considered a "breaking change". It's also more-or-less what the docs say this function does, although they're not specific.

This function no longer searches outside the containing SVG document; if it reaches this.root() without finding a matching element, it returns null.

This is, I think, what most devs would expect. If I call parents('.foo'), I expect the last element in that array to have the class foo. I'm confident most devs would agree.

Fuzzyma commented 2 years ago

Good catch. This method is used so rarely that bugs live forever before they are found (and debugged AND fixed). Thank you very much!