Returning null in template should nullify parent template

This commit is contained in:
Tim van der Lippe
2018-03-15 11:30:06 +01:00
parent 5422bef956
commit 2a6c0a2a10
2 changed files with 37 additions and 2 deletions

View File

@@ -113,6 +113,24 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
</script>
</dom-module>
<dom-module id="parent-element-template-overriding">
<script>
HTMLImports.whenReady(function() {
class ParentElementWithTemplate extends Polymer.Element {
static get template() {
return Polymer.html`This template should not exist`;
}
}
class ChildWithNoTemplate extends ParentElementWithTemplate {
static get template() {
return null;
}
}
customElements.define('child-with-no-template', ChildWithNoTemplate);
});
</script>
</dom-module>
<test-fixture id="basic">
<template>
<base-el></base-el>
@@ -237,6 +255,23 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
assert.equal(child.handleCustomEvent.callCount, 1);
});
});
suite('child overriding a template', function() {
let el;
setup(function() {
el = document.createElement('child-with-no-template');
document.body.appendChild(el);
});
teardown(function() {
document.body.removeChild(el);
});
test('returning null nullifies the parent template', function() {
assert.isNotOk(el.shadowRoot);
});
});
</script>
</body>
</html>
</html>