From a61525e02014062d09f0ce65495d6144636389ef Mon Sep 17 00:00:00 2001 From: Ulrich-Matthias Schäfer Date: Fri, 10 Apr 2020 15:55:22 +1000 Subject: added tests for Pattern --- src/elements/Pattern.js | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'src/elements') diff --git a/src/elements/Pattern.js b/src/elements/Pattern.js index 72b7c59..be03423 100644 --- a/src/elements/Pattern.js +++ b/src/elements/Pattern.js @@ -10,9 +10,23 @@ export default class Pattern extends Container { super(nodeOrNew('pattern', node), attrs) } - // Return the fill id - url () { - return 'url(#' + this.id() + ')' + // custom attr to handle transform + attr (a, b, c) { + if (a === 'transform') a = 'patternTransform' + return super.attr(a, b, c) + } + + bbox () { + return new Box() + } + + targets () { + return baseFind('svg [fill*="' + this.id() + '"]') + } + + // Alias string convertion to fill + toString () { + return this.url() } // Update pattern by rebuilding @@ -28,24 +42,11 @@ export default class Pattern extends Container { return this } - // Alias string convertion to fill - toString () { - return this.url() - } - - // custom attr to handle transform - attr (a, b, c) { - if (a === 'transform') a = 'patternTransform' - return super.attr(a, b, c) - } - - targets () { - return baseFind('svg [fill*="' + this.id() + '"]') + // Return the fill id + url () { + return 'url("#' + this.id() + '")' } - bbox () { - return new Box() - } } registerMethods({ -- cgit v1.2.3