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 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
correct timing of HTMLImports parsing hook installation and add test. F…
- Loading branch information
Showing
3 changed files
with
53 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Custom Elements: imports integration</title> | ||
<script src="../../../tools/test/htmltest.js"></script> | ||
<script src="../../../tools/test/chai/chai.js"></script> | ||
<script> | ||
HTMLImports = {}; | ||
|
||
var elementsCreated = 0; | ||
|
||
addEventListener('load', function() { | ||
setTimeout(function() { | ||
document.dispatchEvent(new CustomEvent('HTMLImportsLoaded', {bubbles: true})); | ||
// parsing hook available | ||
chai.assert.ok(HTMLImports.__importsParsingHook, 'imports parsing hook installed'); | ||
// | ||
var doc = document.implementation.createHTMLDocument('Foo'); | ||
doc.body.innerHTML = '<x-foo></x-foo>'; | ||
var link = document.createElement('mock-link'); | ||
link.import = doc; | ||
HTMLImports.__importsParsingHook(link); | ||
// | ||
addEventListener('WebComponentsReady', function() { | ||
chai.assert.equal(2, elementsCreated, 'HTML hook allows main document and import document to upgrade'); | ||
done(); | ||
}) | ||
}, 1); | ||
}); | ||
</script> | ||
<script src="../../custom-elements.js"></script> | ||
<script> | ||
(function() { | ||
var proto = Object.create(HTMLElement.prototype); | ||
proto.createdCallback = function() { | ||
elementsCreated++; | ||
} | ||
|
||
document.registerElement('x-foo', {prototype: proto}); | ||
})(); | ||
</script> | ||
</head> | ||
<body> | ||
<x-foo></x-foo> | ||
</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