Sitelet https://github.com/popeindustries/inline-source/issues/80
Skip to content

xmlns and src attributes of the even-numbered *.svg source aren't removed #80

Description

@arktds

version: 6.1.8


INPUT: src/html/index.html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title></title>
</head>
<body>
  <img src="../img/right.svg" alt="" inline>
  <img src="../img/right.svg" alt="" inline>
  <img src="../img/right.svg" alt="" inline>
  <img src="../img/right.svg" alt="" inline>
  <img src="../img/left.svg" alt="" inline>
  <img src="../img/left.svg" alt="" inline>
  <img src="../img/left.svg" alt="" inline>
  <img src="../img/left.svg" alt="" inline>
</body>
</html>

src/img/right.svg

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><rect x="6" y="15" width="15" height="2"/><polygon points="20 20 20 12 25 16 20 20"/></svg>

src/img/left.svg

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><rect x="11" y="15" width="15" height="2" transform="translate(37 32) rotate(180)"/><polygon points="12 12 12 20 7 16 12 12"/></svg>

index.js

const { inlineSource } = require('inline-source');
const fs = require('fs');

inlineSource('src/html/index.html')
.then(html => {
  fs.writeFileSync('dist/html/index.html', html);
}).catch(err => {
  console.log('failed');
});

OUTPUT: dist/html/index.html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title></title>
</head>
<body>
  <svg viewBox="0 0 32 32"><path d="M6 15h15v2H6z"/><path d="M20 20v-8l5 4-5 4z"/></svg>
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" src="../img/right.svg"><path d="M6 15h15v2H6z"/><path d="M20 20v-8l5 4-5 4z"/></svg>
  <svg viewBox="0 0 32 32"><path d="M6 15h15v2H6z"/><path d="M20 20v-8l5 4-5 4z"/></svg>
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" src="../img/right.svg"><path d="M6 15h15v2H6z"/><path d="M20 20v-8l5 4-5 4z"/></svg>
  <svg viewBox="0 0 32 32"><path d="M26 17H11v-2h15z"/><path d="M12 12v8l-5-4 5-4z"/></svg>
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" src="../img/left.svg"><path d="M26 17H11v-2h15z"/><path d="M12 12v8l-5-4 5-4z"/></svg>
  <svg viewBox="0 0 32 32"><path d="M26 17H11v-2h15z"/><path d="M12 12v8l-5-4 5-4z"/></svg>
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" src="../img/left.svg"><path d="M26 17H11v-2h15z"/><path d="M12 12v8l-5-4 5-4z"/></svg>
</body>
</html>

EXPECTED: dist/html/index.html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title></title>
</head>
<body>
  <svg viewBox="0 0 32 32"><path d="M6 15h15v2H6z"/><path d="M20 20v-8l5 4-5 4z"/></svg>
  <svg viewBox="0 0 32 32"><path d="M6 15h15v2H6z"/><path d="M20 20v-8l5 4-5 4z"/></svg>
  <svg viewBox="0 0 32 32"><path d="M6 15h15v2H6z"/><path d="M20 20v-8l5 4-5 4z"/></svg>
  <svg viewBox="0 0 32 32"><path d="M6 15h15v2H6z"/><path d="M20 20v-8l5 4-5 4z"/></svg>
  <svg viewBox="0 0 32 32"><path d="M26 17H11v-2h15z"/><path d="M12 12v8l-5-4 5-4z"/></svg>
  <svg viewBox="0 0 32 32"><path d="M26 17H11v-2h15z"/><path d="M12 12v8l-5-4 5-4z"/></svg>
  <svg viewBox="0 0 32 32"><path d="M26 17H11v-2h15z"/><path d="M12 12v8l-5-4 5-4z"/></svg>
  <svg viewBox="0 0 32 32"><path d="M26 17H11v-2h15z"/><path d="M12 12v8l-5-4 5-4z"/></svg>
</body>
</html>

Activity

  1. changed the title [-]xmls and src attributes of the even-numbered *.svg source aren't removed[/-] [+]xmlns and src attributes of the even-numbered *.svg source aren't removed[/+] on Jan 23, 2019
  2. popeindustries commented on Jan 23, 2019

    @popeindustries
    Owner

    Very strange. Unfortunately, I'm unable to reproduce this behaviour locally. Is there any way you could debug this further?

  3. arktds commented on Jan 24, 2019

    @arktds
    Author

    I created a new project on glitch. I changed the code slightly to work on glitch.

    https://glitch.com/edit/#!/join/c1d83fb2-6295-4273-b4c2-cd696c7560fd

    Click Logs in the sidebar, then see console.
    You can also edit the code.

  4. vincentorback commented on Jun 9, 2019

    @vincentorback

    Can confirm this when using compress: true.
    Also for me, every other svg-element that is inlined still has the src-attribute used on the img-element.

  5. popeindustries commented on Jun 11, 2019

    @popeindustries
    Owner

    should be fixed now in 6.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions