Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: support href attribute in <image /> in collecting dependencies in HTMLTransformer #7482

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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