Skip to content

Commit

Permalink
Feature: support href attribute in <image /> in collecting dependenci…
Browse files Browse the repository at this point in the history
…es in HTMLTransformer (#7482)
  • Loading branch information
Shinyaigeek committed Dec 25, 2021
1 parent 8823770 commit af76afc
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
17 changes: 17 additions & 0 deletions packages/core/integration-tests/test/html.js
Expand Up @@ -965,6 +965,23 @@ describe('html', function () {
]);
});

it("should support href attribute in <image /> in HTMLTransformer's collectDependencies", async function () {
let b = await bundle(
path.join(__dirname, '/integration/html-image-href-attr/index.html'),
);

assertBundles(b, [
{
name: 'index.html',
assets: ['index.html'],
},
{
type: 'png',
assets: ['100x100.png'],
},
]);
});

// Based on https://developer.mozilla.org/en-US/docs/Web/SVG/Element/script
it('should bundle scripts inside svg', async function () {
let b = await bundle(
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,13 @@
<!doctype html>
<html>

<head>
</head>

<body>
<svg>
<image href="./100x100.png" />
</svg>
</body>

</html>
2 changes: 1 addition & 1 deletion packages/transformers/html/src/dependencies.js
Expand Up @@ -18,7 +18,7 @@ const ATTRS = {
'amp-img',
],
// Using href with <script> is described here: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/script
href: ['link', 'a', 'use', 'script'],
href: ['link', 'a', 'use', 'script', 'image'],
srcset: ['img', 'source'],
imagesrcset: ['link'],
poster: ['video'],
Expand Down

0 comments on commit af76afc

Please sign in to comment.