Currently, when renumerateIRIElements: true (the default), all IRI-addressable elements are renumerated regardless of their position in the SVG tree. This can be problematic for interactive SVGs where elements outside (e.g. in a US map) need to retain their original IDs for event handling or DOM queries.
Proposed solution
Add a new option (e.g. renumerateScope: 'all' | 'defs') that restricts renumeration to elements inside when set to 'defs'.
Considerations
Elements like <clipPath>, <mask>, <filter> are often defined outside <defs> in real-world SVGs (valid per spec). A defs-only scope would skip those, which could break cross-references in some SVGs. The reference-updating logic would remain unchanged - only the initial element collection phase would be scoped.
Workaround
Set renumerateIRIElements: false to preserve all original IDs (disables renumeration entirely).
Related: #14
Currently, when renumerateIRIElements: true (the default), all IRI-addressable elements are renumerated regardless of their position in the SVG tree. This can be problematic for interactive SVGs where elements outside (e.g. in a US map) need to retain their original IDs for event handling or DOM queries.
Proposed solution
Add a new option (e.g. renumerateScope: 'all' | 'defs') that restricts renumeration to elements inside when set to 'defs'.
Considerations
Elements like
<clipPath>,<mask>,<filter>are often defined outside<defs>in real-world SVGs (valid per spec). A defs-only scope would skip those, which could break cross-references in some SVGs. The reference-updating logic would remain unchanged - only the initial element collection phase would be scoped.Workaround
Set renumerateIRIElements: false to preserve all original IDs (disables renumeration entirely).
Related: #14