mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Handle srcset image density specifications
This commit is contained in:
parent
1f963d64cc
commit
d2bb359f5c
2 changed files with 22 additions and 1 deletions
|
|
@ -562,7 +562,7 @@ Readability.prototype = {
|
|||
|
||||
if (d) {
|
||||
const proxySrc = this.createImageProxyUrl(this.toAbsoluteURI(link));
|
||||
resultSrcset += `${proxySrc} ${d},`;
|
||||
resultSrcset += `${proxySrc} ${d}x,`;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -281,6 +281,27 @@ describe("Readability API", function() {
|
|||
var content = new Readability(dom.window.document).parse().content;
|
||||
expect(content).eql(expected_xhtml);
|
||||
});
|
||||
|
||||
it("should handle srcset elements with density descriptors", function() {
|
||||
var dom = new JSDOM('My image: <img src="https://webkit.org/demos/srcset/image-src.png" ' +
|
||||
'srcset="https://webkit.org/demos/srcset/image-1x.png 1x, ' +
|
||||
'https://webkit.org/demos/srcset/image-2x.png 2x, ' +
|
||||
'https://webkit.org/demos/srcset/image-3x.png 3x, ' +
|
||||
'https://webkit.org/demos/srcset/image-4x.png 4x">'
|
||||
);
|
||||
var expected_xhtml = '<div id="readability-page-1" class="page">My image: ' +
|
||||
'<img src="https://webkit.org/demos/srcset/image-src.png" ' +
|
||||
'srcset="https://webkit.org/demos/srcset/image-1x.png 1x,' +
|
||||
'https://webkit.org/demos/srcset/image-2x.png 2x,' +
|
||||
'https://webkit.org/demos/srcset/image-3x.png 3x,' +
|
||||
'https://webkit.org/demos/srcset/image-4x.png 4x,"></div>';
|
||||
var content = new Readability(dom.window.document, {
|
||||
createImageProxyUrl: function(url) {
|
||||
return url;
|
||||
}
|
||||
}).parse().content;
|
||||
expect(content).eql(expected_xhtml);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue