mirror of
https://github.com/jlengrand/webcomponentsjs.git
synced 2026-03-10 15:53:12 +00:00
52 lines
1.9 KiB
HTML
52 lines
1.9 KiB
HTML
<!doctype html>
|
|
<!--
|
|
@license
|
|
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
|
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
|
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
|
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
|
Code distributed by Google as part of the polymer project is also
|
|
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
|
-->
|
|
<html>
|
|
<head>
|
|
<title>HTML Imports Dynamic</title>
|
|
<script src="../../../src/HTMLImports/HTMLImports.js"></script>
|
|
<script src="../../../../web-component-tester/browser.js"></script>
|
|
</head>
|
|
<body>
|
|
|
|
<script>
|
|
var loads = 0;
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
// some time later
|
|
setTimeout(function() {
|
|
var div = document.createElement('div');
|
|
div.innerHTML = '<link rel="import" href="imports/load-1.html">' +
|
|
'<link rel="import" href="imports/load-2.html">';
|
|
document.body.appendChild(div);
|
|
var ports = document.querySelectorAll('link[rel=import]');
|
|
for (var i=0, l=ports.length, n; (i<l) && (n=ports[i]); i++) {
|
|
n.addEventListener('load', function(e) {
|
|
loads++;
|
|
});
|
|
}
|
|
});
|
|
});
|
|
|
|
test('dynamic loaded details', function(done) {
|
|
HTMLImports.whenReady(function(detail) {
|
|
chai.assert.equal(detail.allImports.length, 2);
|
|
chai.assert.equal(detail.errorImports.length, 0);
|
|
chai.assert.equal(detail.loadedImports.length, 2);
|
|
|
|
chai.expect(detail.loadedImports[0].href).to.contain('imports/load-1.html');
|
|
chai.expect(detail.loadedImports[1].href).to.contain('imports/load-2.html');
|
|
|
|
done();
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|