Skip to content

Commit

Permalink
Removing support for returning strings from template getter.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed May 8, 2018
1 parent bd05abf commit ba4491d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 14 deletions.
5 changes: 2 additions & 3 deletions lib/mixins/element-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,8 @@ export const ElementMixin = dedupingMixin(base => {
let template = /** @type {PolymerElementConstructor} */ (this).template;
if (template) {
if (typeof template === 'string') {
let t = document.createElement('template');
t.innerHTML = template;
template = t;
console.error('template getter must return HTMLTemplateElement');
template = null;
} else {
template = template.cloneNode(true);
}
Expand Down
6 changes: 3 additions & 3 deletions test/smoke/ordering-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
<body>

<script type="module">
import { PolymerElement } from '../../polymer-element.js';
import { PolymerElement, html } from '../../polymer-element.js';
class XA extends PolymerElement {
static get template() {
return `<x-b prop="[[prop]]"></x-b>`;
return html`<x-b prop="[[prop]]"></x-b>`;
}
static get observers() { return ['propChanged(prop)']}
propChanged() {
Expand Down Expand Up @@ -101,7 +101,7 @@

class XC extends PolymerElement {
static get template() {
return `<div></div>`;
return html`<div></div>`;
}
static get observers() { return ['propChanged(prop)']}
propChanged() {
Expand Down
5 changes: 2 additions & 3 deletions test/unit/dom-repeat-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ Polymer({
}
});
let XNestedRepeat = Polymer({
_template: `
_template: html`
<template id="repeater" is="dom-repeat" items="{{items}}" as="itema" index-as="indexa" on-dom-change="domUpdateHandler">
<x-foo on-test1="testHandler1"
innera-prop="{{innera.prop}}"
Expand Down Expand Up @@ -254,8 +254,7 @@ let XNestedRepeat = Polymer({
class XNestedRepeatMutable extends MutableData(XNestedRepeat) {
static get template() {
if (!this._templateEl) {
this._templateEl = document.createElement('template');
this._templateEl.innerHTML = XNestedRepeat.template;
this._templateEl = XNestedRepeat.template.cloneNode(true);
}
return this.makeRepeatsMutable(this._templateEl.cloneNode(true));
}
Expand Down
6 changes: 3 additions & 3 deletions test/unit/polymer.element.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@

<dom-module id="sub-element">
<script type="module">
import '../../polymer-element.js';
import { PolymerElement } from '../../polymer-element.js';

class SubElement extends window.MyElement {

Expand Down Expand Up @@ -247,11 +247,11 @@
</dom-module>

<script type="module">
import '../../polymer-element.js';
import { html } from '../../polymer-element.js';

class SubNewTemplate extends window.MyElement {
static get template() {
return `
return html`
<h1>Sub template</h1>
<div id="subContent">{{prop2}}</div>`;
}
Expand Down
4 changes: 2 additions & 2 deletions test/unit/styling-scoped.html
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@
</style>
</template>
<script type="module">
import { PolymerElement } from '../../polymer-element.js';
import { PolymerElement, html } from '../../polymer-element.js';
customElements.define('x-class-no-is', class extends PolymerElement {
static get template() {
return window.xClass;
Expand All @@ -596,7 +596,7 @@

customElements.define('x-template-string', class extends PolymerElement {
static get template() {
return `<style>
return html`<style>
:host {
display: block;
border: 1px solid orange;
Expand Down

0 comments on commit ba4491d

Please sign in to comment.