diff options
author | wout <wout@impinc.co.uk> | 2014-08-01 20:40:49 +0200 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2014-08-01 20:40:49 +0200 |
commit | f0dc4d5ee03add261242743aa583c19d918f317c (patch) | |
tree | 2d480aed288eb180e53c3c0fba8623029478db8b /README.md | |
parent | c2d1b2916b38d111d8672826c1219ab891567798 (diff) | |
download | svg.js-f0dc4d5ee03add261242743aa583c19d918f317c.tar.gz svg.js-f0dc4d5ee03add261242743aa583c19d918f317c.zip |
Added SVG.Bare for creation of non-described elements
Diffstat (limited to 'README.md')
-rwxr-xr-x | README.md | 34 |
1 files changed, 32 insertions, 2 deletions
@@ -798,10 +798,40 @@ symbol.rect(100, 100).fill('#f09') var use = draw.use(symbol).move(200, 200) ``` -__`returns`: `SVG.Symbol`__ +__`returns`: `SVG.Bare`__ -_Javascript inheritance stack: `SVG.Symbol` < `SVG.Container` < `SVG.Element`_ +_Javascript inheritance stack: `SVG.Bare` < `SVG.Element` [with a shallow inheritance from `SVG.Parent`]_ +## Bare +For all SVG elements that are not described by SVG.js, the `SVG.Bare` class comes in handy. This class inherits directly from `SVG.Element` and makes it possible to add custom methods in a separate namespace. + +### element() +the `SVG.Bare` class can be instantiated with the `element()` method on any parent element: + +```javascript +var element = draw.element('title') +``` +The stirng value passed as the first argument is the node name that should be generated. + +Additionally the class name can be passed as the second argument from which the element should inherit: + +```javascript +var element = draw.element('symbol', SVG.Parent) +``` + +This gives you as the user a lot of power. But remember, with great power comes great responsibility. + +__`returns`: `SVG.Bare`__ + +### words() +The `SVG.Bare` instance carries an additional method to add plain text: + +```javascript +var element = draw.element('title').words('This is a title.') +//-> <title>This is a title.</title> +``` + +__`returns`: `itself`__ ## Referencing elements |