0.0.5 • Published 8 years ago

customizable-svg v0.0.5

Weekly downloads
1
License
MIT
Repository
-
Last release
8 years ago

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

wip

License

MIT

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago