Skip to content

Commit 0190e33

Browse files
author
Steven Orvell
committed
Address review feedback
* Uses `window.ShadyCSS.cssBuild` to avoid doing unnecessary work in `processElementStyles` * Stores the list of active in-use behaviors in a legacy element's `behaviors` property. This only matters in the exotic case when elements with behaviors are extended with more behaviors and previously the list included only the subclasses behaviors (although the element otherwise worked as expected).
1 parent efb8d71 commit 0190e33

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

lib/legacy/class.html

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,9 @@
203203

204204
static get properties() {
205205
const properties = {};
206-
if (this.prototype.behaviors) {
207-
for (let i=0, b; i < this.prototype.behaviors.length; i++) {
208-
b = this.prototype.behaviors[i];
206+
if (this.prototype.__behaviors) {
207+
for (let i=0, b; i < this.prototype.__behaviors.length; i++) {
208+
b = this.prototype.__behaviors[i];
209209
mergeProperties(properties, b.properties);
210210
}
211211
}
@@ -215,9 +215,9 @@
215215

216216
static get observers() {
217217
let observers = [];
218-
if (this.prototype.behaviors) {
219-
for (let i=0, b; i < this.prototype.behaviors.length; i++) {
220-
b = this.prototype.behaviors[i];
218+
if (this.prototype.__behaviors) {
219+
for (let i=0, b; i < this.prototype.__behaviors.length; i++) {
220+
b = this.prototype.__behaviors[i];
221221
if (b.observers) {
222222
observers = observers.concat(b.observers);
223223
}
@@ -273,8 +273,8 @@
273273
`is` in `beforeRegister` as you could in 1.x.
274274
*/
275275
const proto = this;
276-
if (proto.hasOwnProperty('behaviors')) {
277-
copyBehaviorProperties(proto.behaviors, proto.constructor);
276+
if (proto.hasOwnProperty('__behaviors')) {
277+
copyBehaviorProperties(proto.__behaviors, proto.constructor);
278278
}
279279
proto.__behaviorMetaProps = proto.__behaviorMetaProps || {};
280280
copyProperties(info, proto);
@@ -420,12 +420,12 @@
420420
if (!Array.isArray(behaviors)) {
421421
behaviors = [behaviors];
422422
}
423-
let superBehaviors = PolymerGenerated.prototype.__allBehaviors;
423+
let superBehaviors = PolymerGenerated.prototype.behaviors;
424424
// get flattened, deduped list of behaviors *not* already on super class
425425
behaviors = flattenBehaviors(behaviors, null, superBehaviors);
426-
PolymerGenerated.prototype.__allBehaviors = superBehaviors ?
426+
PolymerGenerated.prototype.behaviors = superBehaviors ?
427427
superBehaviors.concat(behaviors) : behaviors;
428-
PolymerGenerated.prototype.behaviors = behaviors;
428+
PolymerGenerated.prototype.__behaviors = behaviors;
429429
}
430430

431431
PolymerGenerated.generatedFrom = info;

lib/mixins/element-mixin.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
(function() {
2222
'use strict';
2323

24+
const builtCSS = window.ShadyCSS && window.ShadyCSS['cssBuild'];
25+
2426
/**
2527
* Element class mixin that provides the core API for Polymer's meta-programming
2628
* features including template stamping, data-binding, attribute deserialization,
@@ -252,7 +254,7 @@
252254
* @private
253255
*/
254256
function processElementStyles(klass, template, is, baseURI) {
255-
if (!window.skipStyleIncludesAndUrls) {
257+
if (!builtCSS) {
256258
const templateStyles = template.content.querySelectorAll('style');
257259
const stylesWithImports = Polymer.StyleGather.stylesFromTemplate(template);
258260
// insert styles from <link rel="import" type="css"> at the top of the template

test/unit/mixin-behaviors.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@
551551
});
552552

553553
test('nested-behavior dedups', function() {
554-
assert.equal(el.behaviors.length, 2);
554+
assert.equal(el.behaviors.length, 6);
555555
});
556556

557557
test('nested-behavior lifecycle', function() {

0 commit comments

Comments
 (0)