Skip to content

Commit

Permalink
Add deprecation notice for class.template returning a string
Browse files Browse the repository at this point in the history
Load `Polymer.html` fn by default with `PolymerElement`.
  • Loading branch information
dfreedm committed Dec 5, 2017
1 parent bdfa5fc commit 530a68b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/mixins/element-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<link rel="import" href="../utils/case-map.html">
<link rel="import" href="../utils/style-gather.html">
<link rel="import" href="../utils/resolve-url.html">
<link rel="import" href="../utils/html-fn.html">
<link rel="import" href="../elements/dom-module.html">
<link rel="import" href="property-effects.html">

Expand Down Expand Up @@ -270,6 +271,8 @@
let template = /** @type {PolymerElementConstructor} */ (klass).template;
if (template) {
if (typeof template === 'string') {
console.warn('String templates are deprecated. ' +
`Please return a <template>, or use Polymer.html\`\` for element <${klass.is}>`);
let t = document.createElement('template');
t.innerHTML = template;
template = t;
Expand Down
11 changes: 10 additions & 1 deletion test/smoke/html-fn.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<head>
<script src="../../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../../polymer-element.html">
<link rel="import" href="../../lib/utils/html-fn.html">
</head>
<body>
<script>
Expand Down Expand Up @@ -50,6 +49,16 @@ <h3 id="name">${this.is}</h3>
}
customElements.define(SubClass.is, SubClass);
</script>
<script>
class XString extends Polymer.Element {
static get is() {return 'x-string'};
static get template() {
return 'string template!';
}
}
customElements.define(XString.is, XString);
</script>
<super-class></super-class>
<sub-class></sub-class>
<x-string></x-string>
</body>

0 comments on commit 530a68b

Please sign in to comment.