Skip to content

Commit

Permalink
Find a[href] dependencies when attrs precede it (#487)
Browse files Browse the repository at this point in the history
  • Loading branch information
ipmb authored and devongovett committed Jan 4, 2018
1 parent e0e231e commit 39c5cfe
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/assets/HTMLAsset.js
Expand Up @@ -44,7 +44,7 @@ class HTMLAsset extends Asset {
let elements = ATTRS[attr];
// Check for virtual paths
if (node.tag === 'a' && node.attrs[attr].lastIndexOf('.') < 1) {
break;
continue;
}
if (elements && elements.includes(node.tag)) {
let assetPath = this.addURLDependency(node.attrs[attr]);
Expand Down
16 changes: 16 additions & 0 deletions test/html.js
Expand Up @@ -48,6 +48,22 @@ describe('html', function() {
}
});

it('should find href attr when not first', async function() {
let b = await bundle(__dirname + '/integration/html-attr-order/index.html');

assertBundleTree(b, {
name: 'index.html',
assets: ['index.html'],
childBundles: [
{
type: 'html',
assets: ['other.html'],
childBundles: []
}
]
});
});

it('should support transforming HTML with posthtml', async function() {
let b = await bundle(__dirname + '/integration/posthtml/index.html');

Expand Down
9 changes: 9 additions & 0 deletions test/integration/html-attr-order/index.html
@@ -0,0 +1,9 @@
<!doctype html>
<html>
<head>
</head>
<body>
<h1>Hello world</h1>
<p>Linking to <a class="link" href="other.html">another page</a></p>
</body>
</html>
8 changes: 8 additions & 0 deletions test/integration/html-attr-order/other.html
@@ -0,0 +1,8 @@
<!doctype html>
<html>
<head>
</head>
<body>
<h1>Other page</h1>
</body>
</html>

0 comments on commit 39c5cfe

Please sign in to comment.