Skip to content

Commit

Permalink
Explicitly making an element's _template falsy is now considered an…
Browse files Browse the repository at this point in the history
… allowable setting. This means the element stamps no content, doesn't collect any styles, and avoids looking up a dom-module. This helps address #2708 and the 5 elements Polymer registers that have no template have been set with `_template: null`.
  • Loading branch information
Steven Orvell committed Nov 10, 2015
1 parent 4f9c2bd commit b905a37
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/lib/custom-style.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@

is: 'custom-style',
extends: 'style',
_template: null,

properties: {
// include is a property so that it deserializes
Expand Down
1 change: 1 addition & 0 deletions src/lib/template/array-selector.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@

Polymer({
is: 'array-selector',
_template: null,

properties: {

Expand Down
1 change: 1 addition & 0 deletions src/lib/template/dom-bind.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
is: 'dom-bind',

extends: 'template',
_template: null,

created: function() {
// Ensure dom-bind doesn't stamp until all possible dependencies
Expand Down
1 change: 1 addition & 0 deletions src/lib/template/dom-if.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

is: 'dom-if',
extends: 'template',
_template: null,

/**
* Fired whenever DOM is added or removed/hidden by this template (by
Expand Down
1 change: 1 addition & 0 deletions src/lib/template/dom-repeat.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@

is: 'dom-repeat',
extends: 'template',
_template: null,

/**
* Fired whenever DOM is added or removed by this template (by
Expand Down
1 change: 1 addition & 0 deletions src/lib/template/dom-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

is: 'dom-template',
extends: 'template',
_template: null,

behaviors: [
Polymer.Templatizer
Expand Down
5 changes: 3 additions & 2 deletions src/mini/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@

_prepTemplate: function() {
// locate template using dom-module
this._template =
this._template || Polymer.DomModule.import(this.is, 'template');
if (this._template === undefined) {
this._template = Polymer.DomModule.import(this.is, 'template');
}
// stick finger in footgun
if (this._template && this._template.hasAttribute('is')) {
this._warn(this._logf('_prepTemplate', 'top-level Polymer template ' +
Expand Down
22 changes: 13 additions & 9 deletions src/standard/styling.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,20 @@
this._encapsulateStyle = !nativeShadow &&
Boolean(this._template);
}
this._styles = this._collectStyles();
var cssText = styleTransformer.elementStyles(this);
if (cssText && this._template) {
var style = styleUtil.applyCss(cssText, this.is,
nativeShadow ? this._template.content : null);
// keep track of style when in document scope (polyfill) so we can
// attach property styles after it.
if (!nativeShadow) {
this._scopeStyle = style;
if (this._template) {
this._styles = this._collectStyles();
var cssText = styleTransformer.elementStyles(this);
if (cssText) {
var style = styleUtil.applyCss(cssText, this.is,
nativeShadow ? this._template.content : null);
// keep track of style when in document scope (polyfill) so we can
// attach property styles after it.
if (!nativeShadow) {
this._scopeStyle = style;
}
}
} else {
this._styles = [];
}
},

Expand Down

0 comments on commit b905a37

Please sign in to comment.