diff options
author | wout <wout@impinc.co.uk> | 2014-07-23 11:44:50 +0200 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2014-07-23 11:44:50 +0200 |
commit | 94077ff77815f622f6ad0daebf26160ec33e0271 (patch) | |
tree | 12e9ab6df8e3fe699f2489ea3d57fe2b8b15239b /src/svg.js | |
parent | 6ac0193538a6358d017875c3a4b183f76894daeb (diff) | |
download | svg.js-94077ff77815f622f6ad0daebf26160ec33e0271.tar.gz svg.js-94077ff77815f622f6ad0daebf26160ec33e0271.zip |
Moved SVG.invent to main svg.js file
Diffstat (limited to 'src/svg.js')
-rwxr-xr-x | src/svg.js | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -55,6 +55,30 @@ SVG.extend = function() { SVG.Set.inherit() } +// Invent new element +SVG.invent = function(config) { + /* create element initializer */ + var initializer = typeof config.create == 'function' ? + config.create : + function() { + this.constructor.call(this, SVG.create(config.create)) + } + + /* inherit prototype */ + if (config.inherit) + initializer.prototype = new config.inherit + + /* extend with methods */ + if (config.extend) + SVG.extend(initializer, config.extend) + + /* attach construct method to parent */ + if (config.construct) + SVG.extend(config.parent || SVG.Container, config.construct) + + return initializer +} + // Initialize parsing element SVG.prepare = function(element) { /* select document body and create invisible svg element */ |