From 09e7d0b595da5a2e86e375ea4bd9bd7aba02c588 Mon Sep 17 00:00:00 2001 From: Ulrich-Matthias Schäfer Date: Thu, 8 Nov 2018 19:49:49 +0100 Subject: added possibility to pass in additional attribues to element creators (#796) e.g. - `canvas.rect({x:100})` or - `canvas.rect(100, 100, {x:100})` --- src/elements/Pattern.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/elements/Pattern.js') diff --git a/src/elements/Pattern.js b/src/elements/Pattern.js index 4a1eee0..6dd4e01 100644 --- a/src/elements/Pattern.js +++ b/src/elements/Pattern.js @@ -1,4 +1,4 @@ -import { nodeOrNew, register } from '../utils/adopter.js' +import { nodeOrNew, register, wrapWithAttrCheck } from '../utils/adopter.js' import { registerMethods } from '../utils/methods.js' import Box from '../types/Box.js' import Container from './Container.js' @@ -51,12 +51,12 @@ export default class Pattern extends Container { registerMethods({ Container: { // Create pattern element in defs - pattern (width, height, block) { - return this.defs().pattern(width, height, block) + pattern (...args) { + return this.defs().pattern(...args) } }, Defs: { - pattern (width, height, block) { + pattern: wrapWithAttrCheck(function (width, height, block) { return this.put(new Pattern()).update(block).attr({ x: 0, y: 0, @@ -64,7 +64,7 @@ registerMethods({ height: height, patternUnits: 'userSpaceOnUse' }) - } + }) } }) -- cgit v1.2.3