Skip to content

Commit

Permalink
Minor renaming based on review.
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Orvell committed Nov 6, 2018
1 parent 9e14172 commit b12a0b6
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions lib/legacy/class.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@
attributeChanged: true,
};

const noCopyProps = Object.assign({
const excludeProps = Object.assign({
behaviors: true
}, metaProps);

const filteredProps = Object.assign({
const lifecycleProps = Object.assign({
listeners: true,
hostAttributes: true
}, metaProps);

function copyProperties(source, target) {
for (let p in source) {
// NOTE: cannot copy `noCopyProps` methods onto prototype at least because
// NOTE: cannot copy `excludeProps` methods onto prototype at least because
// `super.ready` must be called and is not included in the user fn.
if (!(p in noCopyProps)) {
if (!(p in excludeProps)) {
let pd = Object.getOwnPropertyDescriptor(source, p);
if (pd) {
Object.defineProperty(target, p, pd);
Expand Down Expand Up @@ -95,18 +95,18 @@
// If lifecycle is called (super then me), order is
// (1) C.created, (2) A.created, (3) B.created, (4) element.created
// (again same as 1.x)
function copyAndFilterBehaviors(proto, behaviors, lifecycle) {
function applyBehaviors(proto, behaviors, lifecycle) {
for (let i=0; i<behaviors.length; i++) {
copyAndFilterProperties(proto, behaviors[i], lifecycle);
applyInfo(proto, behaviors[i], lifecycle);
}
}

function copyAndFilterProperties(proto, infoOrBehavior, lifecycle) {
copyProperties(infoOrBehavior, proto);
for (let p in filteredProps) {
if (infoOrBehavior[p]) {
function applyInfo(proto, info, lifecycle) {
copyProperties(info, proto);
for (let p in lifecycleProps) {
if (info[p]) {
lifecycle[p] = lifecycle[p] || [];
lifecycle[p].push(infoOrBehavior[p]);
lifecycle[p].push(info[p]);
}
}
}
Expand Down Expand Up @@ -219,17 +219,17 @@
function GenerateClassFromInfo(info, Base, behaviors) {

// manages behavior and lifecycle processing (filled in after class definition)
let activeBehaviors;
let behaviorList;
const lifecycle = {};

/** @private */
class PolymerGenerated extends Base {

static get properties() {
const properties = {};
if (activeBehaviors) {
for (let i=0, b; i < activeBehaviors.length; i++) {
b = activeBehaviors[i];
if (behaviorList) {
for (let i=0, b; i < behaviorList.length; i++) {
b = behaviorList[i];
mergeElementProperties(properties, b.properties);
}
}
Expand All @@ -239,9 +239,9 @@

static get observers() {
let observers = [];
if (activeBehaviors) {
for (let i=0, b; i < activeBehaviors.length; i++) {
b = activeBehaviors[i];
if (behaviorList) {
for (let i=0, b; i < behaviorList.length; i++) {
b = behaviorList[i];
if (b.observers) {
observers = observers.concat(b.observers);
}
Expand Down Expand Up @@ -279,10 +279,10 @@
`is` in `beforeRegister` as you could in 1.x.
*/
const proto = this;
if (activeBehaviors) {
copyAndFilterBehaviors(proto, activeBehaviors, lifecycle);
if (behaviorList) {
applyBehaviors(proto, behaviorList, lifecycle);
}
copyAndFilterProperties(proto, info, lifecycle);
applyInfo(proto, info, lifecycle);
let list = lifecycle.beforeRegister;
if (list) {
for (let i=0; i < list.length; i++) {
Expand Down Expand Up @@ -403,9 +403,9 @@
}
let superBehaviors = Base.prototype.behaviors;
// get flattened, deduped list of behaviors *not* already on super class
activeBehaviors = flattenBehaviors(behaviors, null, superBehaviors);
behaviorList = flattenBehaviors(behaviors, null, superBehaviors);
PolymerGenerated.prototype.behaviors = superBehaviors ?
superBehaviors.concat(behaviors) : activeBehaviors;
superBehaviors.concat(behaviors) : behaviorList;
}

PolymerGenerated.generatedFrom = info;
Expand Down

0 comments on commit b12a0b6

Please sign in to comment.