@polymer/polymer
Version:
The Polymer library makes it easy to create your own web components. Give your element some markup and properties, and then use it on a site. Polymer provides features like dynamic templates and data binding to reduce the amount of boilerplate you need to
68 lines (56 loc) • 2.23 kB
HTML
<!--
@license
Copyright (c) 2017 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>
<meta charset="utf-8">
<script src="../../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../../web-component-tester/browser.js"></script>
<link rel="import" href="../../lib/utils/import-href.html">
<body>
<x-test></x-test>
<script>
suite('importHref', function() {
let parsedEl = document.querySelector('x-test');
test('importing polymer via Polymer.importHref', function(done) {
assert.notOk(Polymer.Element);
Polymer.importHref('../../polymer.html', function() {
assert.ok(Polymer.Element);
done();
});
});
test('element loaded with Polymer.Base.importHref upgrades properly', function(done) {
Polymer.Base.importHref('sub/x-test.html', function() {
assert.ok(parsedEl.$.sub, 'parsed element not upgraded with template when import loaded');
assert.notOk(parsedEl.$.sub.$, 'sub element of imported element should not yet be upgraded');
var el = document.createElement('x-test');
document.body.appendChild(el);
assert.ok(el.$.sub, 'imperatively created element not upgraded with template when import loaded');
done();
});
});
test('sub-element loaded with instance importHref upgrades properly', function(done) {
parsedEl.importHref('sub/x-sub.html', function() {
assert.equal(this, parsedEl);
assert.ok(parsedEl.$.sub.$.test, 'sub element not upgraded when import loaded');
done();
});
});
test('load is triggered on second call', function(done) {
Polymer.Base.importHref('sub/x-test.html', function() {
Polymer.Base.importHref('sub/x-test.html', function() {
done();
});
});
});
});
</script>
</body>
</html>