mirror of
https://github.com/Polymer/polymer.git
synced 2026-08-19 01:14:44 -05:00
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).
This commit is contained in:
+11
-11
@@ -203,9 +203,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
|
||||
static get properties() {
|
||||
const properties = {};
|
||||
if (this.prototype.behaviors) {
|
||||
for (let i=0, b; i < this.prototype.behaviors.length; i++) {
|
||||
b = this.prototype.behaviors[i];
|
||||
if (this.prototype.__behaviors) {
|
||||
for (let i=0, b; i < this.prototype.__behaviors.length; i++) {
|
||||
b = this.prototype.__behaviors[i];
|
||||
mergeProperties(properties, b.properties);
|
||||
}
|
||||
}
|
||||
@@ -215,9 +215,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
|
||||
static get observers() {
|
||||
let observers = [];
|
||||
if (this.prototype.behaviors) {
|
||||
for (let i=0, b; i < this.prototype.behaviors.length; i++) {
|
||||
b = this.prototype.behaviors[i];
|
||||
if (this.prototype.__behaviors) {
|
||||
for (let i=0, b; i < this.prototype.__behaviors.length; i++) {
|
||||
b = this.prototype.__behaviors[i];
|
||||
if (b.observers) {
|
||||
observers = observers.concat(b.observers);
|
||||
}
|
||||
@@ -273,8 +273,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
`is` in `beforeRegister` as you could in 1.x.
|
||||
*/
|
||||
const proto = this;
|
||||
if (proto.hasOwnProperty('behaviors')) {
|
||||
copyBehaviorProperties(proto.behaviors, proto.constructor);
|
||||
if (proto.hasOwnProperty('__behaviors')) {
|
||||
copyBehaviorProperties(proto.__behaviors, proto.constructor);
|
||||
}
|
||||
proto.__behaviorMetaProps = proto.__behaviorMetaProps || {};
|
||||
copyProperties(info, proto);
|
||||
@@ -420,12 +420,12 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
if (!Array.isArray(behaviors)) {
|
||||
behaviors = [behaviors];
|
||||
}
|
||||
let superBehaviors = PolymerGenerated.prototype.__allBehaviors;
|
||||
let superBehaviors = PolymerGenerated.prototype.behaviors;
|
||||
// get flattened, deduped list of behaviors *not* already on super class
|
||||
behaviors = flattenBehaviors(behaviors, null, superBehaviors);
|
||||
PolymerGenerated.prototype.__allBehaviors = superBehaviors ?
|
||||
PolymerGenerated.prototype.behaviors = superBehaviors ?
|
||||
superBehaviors.concat(behaviors) : behaviors;
|
||||
PolymerGenerated.prototype.behaviors = behaviors;
|
||||
PolymerGenerated.prototype.__behaviors = behaviors;
|
||||
}
|
||||
|
||||
PolymerGenerated.generatedFrom = info;
|
||||
|
||||
@@ -21,6 +21,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
const builtCSS = window.ShadyCSS && window.ShadyCSS['cssBuild'];
|
||||
|
||||
/**
|
||||
* Element class mixin that provides the core API for Polymer's meta-programming
|
||||
* features including template stamping, data-binding, attribute deserialization,
|
||||
@@ -252,7 +254,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
* @private
|
||||
*/
|
||||
function processElementStyles(klass, template, is, baseURI) {
|
||||
if (!window.skipStyleIncludesAndUrls) {
|
||||
if (!builtCSS) {
|
||||
const templateStyles = template.content.querySelectorAll('style');
|
||||
const stylesWithImports = Polymer.StyleGather.stylesFromTemplate(template);
|
||||
// insert styles from <link rel="import" type="css"> at the top of the template
|
||||
|
||||
@@ -551,7 +551,7 @@ suite('nested-behaviors element', function() {
|
||||
});
|
||||
|
||||
test('nested-behavior dedups', function() {
|
||||
assert.equal(el.behaviors.length, 2);
|
||||
assert.equal(el.behaviors.length, 6);
|
||||
});
|
||||
|
||||
test('nested-behavior lifecycle', function() {
|
||||
|
||||
Reference in New Issue
Block a user