Comparing version 0.0.10 to 0.1.0
31
index.js
@@ -18,12 +18,3 @@ module.exports = svg; | ||
var attributes = Object.keys(attrBag); | ||
for (var i = 0; i < attributes.length; ++i) { | ||
var attributeName = attributes[i]; | ||
var value = attrBag[attributeName]; | ||
if (attributeName === 'link') { | ||
svgElement.link(value); | ||
} else { | ||
svgElement.attr(attributeName, value); | ||
} | ||
} | ||
svgElement.attr(attrBag); | ||
@@ -92,4 +83,22 @@ return svgElement; | ||
} | ||
if (typeof name === 'string') { | ||
// someone wants to get value of an attribute: | ||
return svgElement.getAttributeNS(null, name); | ||
} | ||
return svgElement.getAttributeNS(null, name); | ||
if (typeof name !== 'object') throw new Error('attr() expects to have either string or object as first argument'); | ||
var attrBag = name; | ||
var attributes = Object.keys(attrBag); | ||
for (var i = 0; i < attributes.length; ++i) { | ||
var attributeName = attributes[i]; | ||
var value = attrBag[attributeName]; | ||
if (attributeName === 'link') { | ||
svgElement.link(value); | ||
} else { | ||
svgElement.attr(attributeName, value); | ||
} | ||
} | ||
return svgElement; | ||
} | ||
@@ -96,0 +105,0 @@ |
{ | ||
"name": "simplesvg", | ||
"version": "0.0.10", | ||
"version": "0.1.0", | ||
"description": "A very simple svg wrapper, inspired by original vivagraph", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"build": "browserify -s sivg ./index.js > dist/simplesvg.js && uglifyjs dist/simplesvg.js > dist/simplesvg.min.js" | ||
}, | ||
@@ -9,0 +10,0 @@ "keywords": [ |
@@ -5,2 +5,20 @@ # simplesvg | ||
# usage | ||
This API is still not very stable. But here is quick example: | ||
``` js | ||
var svg = require('simplesvg'); | ||
var circle = svg('circle', { | ||
r: 21, | ||
cx: 42, | ||
cy: 42, | ||
stroke: '#000', | ||
fill: 'deepskyblue' | ||
}); | ||
// `circle` is a regular DOM element, you can append it to parent: | ||
document.getElementById('scene').appendChild(circle); | ||
``` | ||
# install | ||
@@ -7,0 +25,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33252
13
720
34
4
6