Skip to content

Commit

Permalink
Fix attribute names changed (#371)
Browse files Browse the repository at this point in the history
Closes #369
  • Loading branch information
s0ph1e authored Aug 28, 2019
1 parent 6c31bf5 commit 6988b86
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/resource-handler/html/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ function prepareToLoad ($, resource) {

function loadTextToCheerio (text) {
return cheerio.load(text, {
decodeEntities: false
decodeEntities: false,
lowerCaseAttributeNames: false,
});
}

Expand Down
20 changes: 20 additions & 0 deletions test/unit/resource-handler/html.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,26 @@ describe('ResourceHandler: Html', () => {
});
});

it('should not update attribute names to lowercase', () => {
htmlHandler = new HtmlHandler({ sources: [] }, {downloadChildrenPaths});
const html = `
<html>
<body>
<svg width="50" height="50" viewBox="0 0 100 100">
<ellipse cx="50" cy="50" rx="50" ry="50"></ellipse>
</svg>
</body>
</html>
`;

const resource = new Resource('http://example.com', 'index.html');
resource.setText(html);

return htmlHandler.handle(resource).then(() => {
resource.getText().should.containEql('viewBox="0 0 100 100"');
});
});

it('should call downloadChildrenResources for each source', () => {
const sources = [{ selector: 'img', attr: 'src' }];
htmlHandler = new HtmlHandler({sources}, {downloadChildrenPaths});
Expand Down

0 comments on commit 6988b86

Please sign in to comment.