Giter Club home page Giter Club logo

Comments (3)

waruyama avatar waruyama commented on June 2, 2024 1

Thanks for the feedback. This is basically a duplicate of issue #28, which also sees some IDs not being replaced.

While your pull request will work for your specific case, I would prefer a more general approach, that will also work if <g>, <rect>, <symbol> etc. elements have an ID. The concept for this approach is already in the drawer, here is the pseudo code:

collect all elements with an "id" attribute (idElements)
IF idElements is not empty THEN
  FOR EACH element IN idElements
    add ID to a set (idSet)
    IF type of element is property referenceable THEN
      add referenceable properties to a set (referencingPropertiesSet)
    ENDIF
    add suffix to element's ID
  ENDFOR

  FOR EACH element IN all elements
    IF element has attributes THEN
    
      IF element has a `href` or `xlink:href` attribute THEN
        IF referenced ID is in idSet THEN
          add suffix to referenced ID
        ENDIF
      ENDIF
    
      FOR EACH property IN referencingPropertiesSet
        IF element's attribute value for property is url with ID THEN
          add suffix to ID in url
        ENDIF
      ENDFOR
    
    ENDIF
  ENDFOR  
 
ENDIF

Also, we will probably add an option to select if all IDs, no IDs, or only IDs that are referenced within the SVG will be made unique.

I hope this will be available in a new version at the beginning of next week.

from svg-inject.

bfollington avatar bfollington commented on June 2, 2024

Awesome! Thanks for responding so fast. That psuedocode approach seems like the right way to go given the broader context, keen for the new release. I'll keep an eye on things :)

from svg-inject.

waruyama avatar waruyama commented on June 2, 2024

Fixed in version 1.2.3. All IDs in the SVG are now made unique by default.

from svg-inject.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.