svgson icon indicating copy to clipboard operation
svgson copied to clipboard

Querying with selectors?

Open bgmort opened this issue 3 years ago • 3 comments

Before I write something myself, is there an existing library somewhere to query the svgson tree using CSS-like selectors?

Example:

const rects = querySelector('#namedGroup rect')
rects.forEach(rect => {
    rect.attributes.fill = 'red'
})

bgmort avatar Aug 20 '21 16:08 bgmort

Hi @bgmort, thanks for open the Issue.

Don't know, but super curious on what you build over in that case!

elrumordelaluz avatar Aug 20 '21 18:08 elrumordelaluz

@bgmort

If you are in a Browser environment, you can use DOMParser to do exactly what you're asking.

If you are in a NodeJS environment, you can accomplish the same using jsdom.

LiamAttClarke avatar Jun 13 '22 18:06 LiamAttClarke

@LiamAttClarke thank you! I don't remember what I was wanting to do with it back in August, but that's good info to have.

bgmort avatar Jun 13 '22 18:06 bgmort