This repository has been archived by the owner on Mar 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support elements dynamically added that do not require loading.
- Loading branch information
Showing
5 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>HTML Imports Dynamic Elements</title> | ||
<script src="../../../tools/test/htmltest.js"></script> | ||
<script src="../../../tools/test/chai/chai.js"></script> | ||
<script src="../../html-imports.js"></script> | ||
<link rel="import" href="imports/dynamic-elements-import.html"> | ||
</head> | ||
<body> | ||
<div id="asyncStyled">red?</div> | ||
|
||
<script> | ||
document.addEventListener('asyncElementsAdded', function() { | ||
HTMLImports.whenImportsReady(function() { | ||
chai.assert.isTrue(window.asyncScript, 'async added script ran'); | ||
var computed = getComputedStyle(document.querySelector('#asyncStyled')); | ||
chai.assert.equal(computed.backgroundColor, 'rgb(255, 0, 0)', 'async added style applied'); | ||
done(); | ||
}); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<script> | ||
(function() { | ||
var doc = document._currentScript.ownerDocument; | ||
setTimeout(function() { | ||
var script = doc.createElement('script') | ||
script.textContent = 'window.asyncScript = true;'; | ||
doc.body.appendChild(script); | ||
|
||
var style = doc.createElement('style'); | ||
style.textContent = '#asyncStyled { background: red; }'; | ||
doc.body.appendChild(style); | ||
|
||
// async for MO. | ||
requestAnimationFrame(function() { | ||
document.dispatchEvent(new CustomEvent('asyncElementsAdded', {bubbles: true})); | ||
}); | ||
}, 100); | ||
})(); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters