diff --git a/src/HTMLImports.js b/src/HTMLImports.js index f4f1daa..3e35200 100644 --- a/src/HTMLImports.js +++ b/src/HTMLImports.js @@ -135,7 +135,7 @@ Loader.prototype = { } if (this.cache[inUrl]) { // complete load using cache data - this.onload(inElt, inUrl, loader.cache[inUrl]); + this.onload(inUrl, inElt, loader.cache[inUrl]); // finished this transaction this.tail(); // don't need fetch @@ -157,7 +157,7 @@ Loader.prototype = { } loader.pending[inUrl].forEach(function(e) { if (!inErr) { - this.onload(inUrl, inElt, inResource); + this.onload(inUrl, e, inResource); } this.tail(); }, this); diff --git a/test/html/HTMLImports.html b/test/html/HTMLImports.html index bf73a8b..bd6f694 100644 --- a/test/html/HTMLImports.html +++ b/test/html/HTMLImports.html @@ -19,6 +19,17 @@ 'must cache exactly five resources'); chai.assert.equal(4, Object.keys(HTMLImports.documents).length, 'must cache exactly four documents'); + + Object.keys(HTMLImports.documents).forEach(function(key) { + var doc = HTMLImports.documents[key]; + var links = doc.querySelectorAll('link[rel=import]'); + Array.prototype.forEach.call(links, function(link) { + var href = link.getAttribute('href'); + if (href.indexOf('404') <= 0) { + chai.assert.isDefined(link.content, 'import should have content'); + } + }); + }) done(); });