0.0.5 • Published 8 years ago
customizable-svg v0.0.5
customizable-svg
The library for customizing svg object with list of properties.
Basic usage
const svg = document.querySelector('svg');
const props = [
{
type: 'style',
value: 'font-size: 200px'
},
{
type: 'text',
value: 'test'
}
];
const customizer = new SVGCustomizer();
customizer.update(svg, 'name', props);
Uniqualizing class names inside svg object
const svg = document.querySelector('svg');
SVGCustomizer.uniqualizeClassNames(svg);
This will replace any styles and corresponding class attributes on elements with unique class names.
API
update(SVGElement svg, string propName, [{type: string, value: string}] properties)
uniqualizeClassNames(SVGElement SVG)
collectProps(SVGElement svg)
NodeJS compatibility
Library could be used in nodejs environment with any of DOM libraries for node (for example jsdom).
Custom window object could be specified in SVGCustomizer
constructor:
const dom = new JSDOM('...');
const customizer = new SVGCustomizer(dom.window);
const svg = dom.window.document.querySelector('svg');
customizer.update(svg, 'name', [...]);
Contributing
License
MIT