Skip to content

Commit 6988b86

Browse files
authored
Fix attribute names changed (#371)
Closes #369
1 parent 6c31bf5 commit 6988b86

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

lib/resource-handler/html/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ function prepareToLoad ($, resource) {
8181

8282
function loadTextToCheerio (text) {
8383
return cheerio.load(text, {
84-
decodeEntities: false
84+
decodeEntities: false,
85+
lowerCaseAttributeNames: false,
8586
});
8687
}
8788

test/unit/resource-handler/html.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,26 @@ describe('ResourceHandler: Html', () => {
144144
});
145145
});
146146

147+
it('should not update attribute names to lowercase', () => {
148+
htmlHandler = new HtmlHandler({ sources: [] }, {downloadChildrenPaths});
149+
const html = `
150+
<html>
151+
<body>
152+
<svg width="50" height="50" viewBox="0 0 100 100">
153+
<ellipse cx="50" cy="50" rx="50" ry="50"></ellipse>
154+
</svg>
155+
</body>
156+
</html>
157+
`;
158+
159+
const resource = new Resource('http://example.com', 'index.html');
160+
resource.setText(html);
161+
162+
return htmlHandler.handle(resource).then(() => {
163+
resource.getText().should.containEql('viewBox="0 0 100 100"');
164+
});
165+
});
166+
147167
it('should call downloadChildrenResources for each source', () => {
148168
const sources = [{ selector: 'img', attr: 'src' }];
149169
htmlHandler = new HtmlHandler({sources}, {downloadChildrenPaths});

0 commit comments

Comments
 (0)