mirror of
https://github.com/jlengrand/webcomponentsjs.git
synced 2026-05-10 00:41:22 +00:00
46 lines
1.6 KiB
HTML
46 lines
1.6 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 imports', function(done) {
|
|
// wait a bit for the imports to load, or not
|
|
setTimeout(function() {
|
|
chai.assert.equal(loads, 2);
|
|
done();
|
|
}, 1000);
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|