Skip to content

Commit

Permalink
Fix parsing xml entities (#1371)
Browse files Browse the repository at this point in the history
Ref https://github.com/svg/sax/releases/tag/v0.1.1

This fixes enother case in [regression tests](#1357).
  • Loading branch information
TrySound committed Feb 23, 2021
1 parent c1d5f0f commit 4b4259b
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 40 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
]
},
"dependencies": {
"@trysound/sax": "0.1.0",
"@trysound/sax": "0.1.1",
"chalk": "^4.1.0",
"commander": "^7.1.0",
"css-select": "^3.1.2",
Expand Down
28 changes: 0 additions & 28 deletions test/svg2js/_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,32 +457,4 @@ describe('svg2js', function() {
});

});

describe('entities', function() {
var filepath = PATH.resolve(__dirname, './test.entities.svg'),
root;

before(function(done) {
FS.readFile(filepath, 'utf8', function(err, data) {
if (err) throw err;

root = SVG2JS(data);
done();
});
});

describe('root', function() {
it('should exist', function() {
expect(root).to.exist;
});

it('should have correctly parsed entities', function() {
var attrs = root.content[root.content.length - 1].attrs;

expect(attrs['xmlns:x'].value).to.be.equal('http://ns.adobe.com/Extensibility/1.0/');
expect(attrs['xmlns:graph'].value).to.be.equal('http://ns.adobe.com/Graphs/1.0/');
});
});
});

});
8 changes: 0 additions & 8 deletions test/svg2js/test.entities.svg

This file was deleted.

5 changes: 5 additions & 0 deletions test/svgo/_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,9 @@ describe('svgo', () => {
const result = optimize(original, { input: 'file', path: 'input.svg', js2svg: { pretty: true } });
expect(normalize(result.data)).to.equal(expected);
});
it('should inline entities', async () => {
const [original, expected] = await parseFixture('entities.svg');
const result = optimize(original, { path: 'input.svg', plugins: [], js2svg: { pretty: true } });
expect(normalize(result.data)).to.equal(expected);
});
});
29 changes: 29 additions & 0 deletions test/svgo/entities.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4b4259b

Please sign in to comment.