From f7f6c4b801172ce119d4ea9a650c543670474784 Mon Sep 17 00:00:00 2001 From: Ulrich-Matthias Schäfer Date: Thu, 8 Nov 2018 14:14:05 +0100 Subject: `fill()` and `stroke()` return the fill and stroke attribute when called as getter (#789) --- CHANGELOG.md | 1 + dist/svg.js | 4 ++-- spec/spec/sugar.js | 5 ++--- src/modules/optional/sugar.js | 2 +- todo.md | 4 +--- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d74509..250b7f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -81,6 +81,7 @@ The document follows the conventions described in [“Keep a CHANGELOG”](http: - `SVG.Text.textPath()` returns only the first textpath child - `attr()` excepts array now to get multiple values at once - `SVG.Text.rebuild()` now takes every font-size into account (#512) +- `fill()` and `stroke()` return the fill and stroke attribute when called as getter (#789) ### Fixed - fixed a bug in clipping and masking where empty nodes persists after removal -> __TODO!__ diff --git a/dist/svg.js b/dist/svg.js index ff69c36..bdf49a1 100644 --- a/dist/svg.js +++ b/dist/svg.js @@ -6,7 +6,7 @@ * @copyright Wout Fierens * @license MIT * -* BUILT: Thu Nov 08 2018 13:57:26 GMT+0100 (GMT+01:00) +* BUILT: Thu Nov 08 2018 14:12:10 GMT+0100 (GMT+01:00) */; var SVG = (function () { 'use strict'; @@ -5073,7 +5073,7 @@ var SVG = (function () { extension[m] = function (o) { if (typeof o === 'undefined') { - return this; + return this.attr(m); } if (typeof o === 'string' || Color.isRgb(o) || o instanceof Element) { diff --git a/spec/spec/sugar.js b/spec/spec/sugar.js index 5ec6049..f79d7d5 100644 --- a/spec/spec/sugar.js +++ b/spec/spec/sugar.js @@ -34,10 +34,9 @@ describe('Sugar', function() { expect(rect.attr('fill-rule')).toBe('odd') }) - it('is a nop with no argument given and returns node reference', function() { + it('returns fill color when called as getter', function() { rect.fill('red') - expect(rect.fill()).toBe(rect) - expect(rect.attr('fill')).toBe('red') + expect(rect.fill()).toBe('red') }) }) diff --git a/src/modules/optional/sugar.js b/src/modules/optional/sugar.js index 69f723e..f4c20fc 100644 --- a/src/modules/optional/sugar.js +++ b/src/modules/optional/sugar.js @@ -23,7 +23,7 @@ var sugar = { extension[m] = function (o) { if (typeof o === 'undefined') { - return this + return this.attr(m) } if (typeof o === 'string' || Color.isRgb(o) || (o instanceof Element)) { this.attr(m, o) diff --git a/todo.md b/todo.md index c4536ba..bb71762 100644 --- a/todo.md +++ b/todo.md @@ -4,6 +4,7 @@ - insertAfter - after - before + - ax, ay, amove - Path.js - targets - Element.js @@ -12,9 +13,6 @@ - Style.js - - - # Where We Left Off Saivan -- cgit v1.2.3