Skip to content

Commit

Permalink
smoke test for provoking native element upgrades in an HTMLImports-ty…
Browse files Browse the repository at this point in the history
…pe polypill.
  • Loading branch information
Steven Orvell committed Aug 17, 2016
1 parent 1071390 commit f60c957
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions test/smoke/simulate-import.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!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>simulate imports</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

</head>
<body>
<script>
class MyElement extends HTMLElement {
constructor() {
super();
console.log(this.localName, 'is a custom element!')
}
}
customElements.define('my-element', MyElement);

var holdingPen = document.createElement('div');
function customizedDomFromHTMLString(htmlString) {
holdingPen.innerHTML = htmlString;
var frag = document.createDocumentFragment();
while (holdingPen.firstChild) {
frag.appendChild(holdingPen.firstChild);
}
return frag;
}

var importedString = '<my-element></my-element><my-upgrade></my-upgrade>';

var doc = document.implementation.createHTMLDocument();
doc.body.appendChild(customizedDomFromHTMLString(importedString));


class MyUpgrade extends HTMLElement {
constructor() {
super();
console.log(this.localName, 'is a custom element!')
}
}
customElements.define('my-upgrade', MyUpgrade);
</script>

</body>
</html>

0 comments on commit f60c957

Please sign in to comment.