diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2023-09-03 08:53:28 +0200 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2023-09-03 08:53:28 +0200 |
commit | 70125d5644ecc80ff332e6eb5570e3ba08c05c13 (patch) | |
tree | 27edb25472e06fdcc69593b73490369076f114b1 /spec | |
parent | dd884bc205e1b476497af3fd8cabcdf85c95125e (diff) | |
download | svg.js-70125d5644ecc80ff332e6eb5570e3ba08c05c13.tar.gz svg.js-70125d5644ecc80ff332e6eb5570e3ba08c05c13.zip |
support css vars (fixes #1230)
Diffstat (limited to 'spec')
-rw-r--r-- | spec/spec/modules/optional/css.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/spec/modules/optional/css.js b/spec/spec/modules/optional/css.js index 8a42acf..a0fa701 100644 --- a/spec/spec/modules/optional/css.js +++ b/spec/spec/modules/optional/css.js @@ -34,6 +34,13 @@ describe('css.js', () => { expect(rect.css('fill')).toBe('none') }) + it('correctly returns css vars', () => { + const rect = new Rect({ + style: '--foo: red;' + }) + expect(rect.css('--foo')).toBe('red') + }) + it('returns undefined if css property is not set', () => { const rect = new Rect({ style: 'fill: none; outline-width: 1px; stroke: none' @@ -94,6 +101,22 @@ describe('css.js', () => { }) expect(rect.css({ fill: null, stroke: 'black' }).css('fill')).toBe('') }) + + it('allows single set of css vars', () => { + const rect = new Rect().css('--foo', 'red').css('--foo', 'green') + expect(rect.css()).toEqual({ + '--foo': 'green' + }) + }) + + it('allows multiple set of css vars via object', () => { + const rect = new Rect().css({ '--foo': 'red', '--bar': 'green' }) + + expect(rect.css()).toEqual({ + '--foo': 'red', + '--bar': 'green' + }) + }) }) }) |