Skip to content

Commit

Permalink
Returning null in template should nullify parent template
Browse files Browse the repository at this point in the history
  • Loading branch information
TimvdLippe committed Mar 15, 2018
1 parent 5422bef commit 2a6c0a2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/mixins/element-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,9 @@
} else {
template = template.cloneNode(true);
}
this.prototype._template = template;
}

this.prototype._template = template;
}

/**
Expand Down
37 changes: 36 additions & 1 deletion test/unit/inheritance.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,24 @@
</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>
Expand Down Expand Up @@ -237,6 +255,23 @@
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>

0 comments on commit 2a6c0a2

Please sign in to comment.