tjw-lint / vue3-snapshot-serializer

Vitest/Jest Snapshot Serializer for Vue 3 components
https://TheJaredWilcurt.com/vue-snapshot-serializer
MIT License
3 stars 2 forks source link

Add SVG elements to Void elements list #49

Closed TheJaredWilcurt closed 1 week ago

TheJaredWilcurt commented 1 week ago

SVG elements can be represented as self closing tags, like <path />.

const SELF_CLOSING_SVG_ELEMENTS = Object.freeze([
  'circle',
  'ellipse',
  'line',
  'path',
  'polygon',
  'polyline',
  'rect',
  'stop',
  'use'
]);
const VOID_ELEMENTS = Object.freeze([
  ...SELF_CLOSING_SVG_ELEMENTS,
  'area',
  'base',
  'br',
  'col',
  'embed',
  'hr',
  'img',
  'input',
  'link',
  'meta',
  'param',
  'source',
  'track',
  'wbr'
]);

I think that is fine for now. I could see breaking this up in the future to a conditional boolean of svgElementsAreVoid with a default of true. But I'm assuming most people won't care, so this setting can be skipped until someone requests it.