Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
arktds opened this issue Jan 23, 2019 · 4 comments
Closed

Comments

@arktds
Copy link

arktds commented Jan 23, 2019

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>
@arktds arktds 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 Jan 23, 2019
@popeindustries
Copy link
Owner

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

@arktds
Copy link
Author

arktds commented Jan 24, 2019

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.

@vincentorback
Copy link

vincentorback commented Jun 9, 2019

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.

@popeindustries
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants