aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorMorgan Harris <gormster@me.com>2021-11-23 13:12:44 +1100
committerMorgan Harris <gormster@me.com>2021-11-23 13:12:44 +1100
commite0be375fc57930306999f15c7a7266edb0ba3432 (patch)
treef18fb403ea0e374c44fe565f1521978dd6178af6 /spec
parent180b292968f7b1491757ea9195cb12bf6c12bba9 (diff)
downloadsvg.js-e0be375fc57930306999f15c7a7266edb0ba3432.tar.gz
svg.js-e0be375fc57930306999f15c7a7266edb0ba3432.zip
Return null if `until` not in parent chain
Diffstat (limited to 'spec')
-rw-r--r--spec/spec/elements/Element.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/spec/elements/Element.js b/spec/spec/elements/Element.js
index 5076373..38b862f 100644
--- a/spec/spec/elements/Element.js
+++ b/spec/spec/elements/Element.js
@@ -188,6 +188,20 @@ describe('Element.js', function () {
expect(rect.parents('.foo')).toEqual([ group3 ])
expect(rect.parents('.test:not(.foo)')).toEqual([ group3, group2, group1 ])
})
+
+ it('returns null if the passed element is not an ancestor', () => {
+ const canvas = SVG().addTo(container)
+ const groupA = canvas.group().addClass('test')
+ const group1 = canvas.group()
+ const group2 = group1.group()
+ const group3 = group2.group()
+ const rect = group3.rect(100, 100)
+
+
+ expect(rect.parents('.does-not-exist')).toEqual(null)
+ expect(rect.parents('.test')).toEqual(null)
+ expect(rect.parents(groupA)).toEqual(null)
+ })
})
describe('reference()', () => {