Skip to content

Commit

Permalink
Ensure _template from behaviors takes precedence over is in legacy.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed Nov 1, 2018
1 parent fb5a7e3 commit 08b267f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions lib/legacy/class.html
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,15 @@
Polymer.LegacyElementMixin(HTMLElement));
// decorate klass with registration info
klass.is = info.is;
// To match 1.x behavior, `_template` supplied on a behavior should take
// precedence over dom-module lookup for `is`; this also prevents
// dom-module injection under strictTemplatePolicy for an element that
// would normally get its template from a behavior.
// TODO(sorvell): Remove once "flattened behaviors" lands, since both
// `_template` and `is` will be on the same class after that change
if (klass.prototype._template !== undefined) {
klass.prototype._template = klass.prototype._template;
}
return klass;
};

Expand Down
4 changes: 2 additions & 2 deletions test/unit/behaviors.html
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,8 @@

test('template from base', function() {
var el = fixture('from-base');
assert.ok(el.shadowRoot.querySelector('#from-base'));
assert.notOk(el.shadowRoot.querySelector('#from-behavior1'));
assert.notOk(el.shadowRoot.querySelector('#from-base'));
assert.ok(el.shadowRoot.querySelector('#from-behavior1'));
});

test('template from behavior', function() {
Expand Down

0 comments on commit 08b267f

Please sign in to comment.