From 39c5cfe377be603b16561f914cb9a07c7e5fdd6c Mon Sep 17 00:00:00 2001 From: Peter Baumgartner Date: Thu, 4 Jan 2018 06:00:41 -0700 Subject: [PATCH] Find a[href] dependencies when attrs precede it (#487) --- src/assets/HTMLAsset.js | 2 +- test/html.js | 16 ++++++++++++++++ test/integration/html-attr-order/index.html | 9 +++++++++ test/integration/html-attr-order/other.html | 8 ++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 test/integration/html-attr-order/index.html create mode 100644 test/integration/html-attr-order/other.html diff --git a/src/assets/HTMLAsset.js b/src/assets/HTMLAsset.js index d5a8ac3fba2..64525d1267d 100644 --- a/src/assets/HTMLAsset.js +++ b/src/assets/HTMLAsset.js @@ -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]); diff --git a/test/html.js b/test/html.js index 779f82e6d0e..436fffe0bac 100644 --- a/test/html.js +++ b/test/html.js @@ -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'); diff --git a/test/integration/html-attr-order/index.html b/test/integration/html-attr-order/index.html new file mode 100644 index 00000000000..033a2410eb1 --- /dev/null +++ b/test/integration/html-attr-order/index.html @@ -0,0 +1,9 @@ + + + + + +

Hello world

+

Linking to another page

+ + diff --git a/test/integration/html-attr-order/other.html b/test/integration/html-attr-order/other.html new file mode 100644 index 00000000000..6a4b6d5b384 --- /dev/null +++ b/test/integration/html-attr-order/other.html @@ -0,0 +1,8 @@ + + + + + +

Other page

+ +