From cf30a8cc35e232a69e1d32309c1f54b94e5f6c1a Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Fri, 9 Nov 2018 11:31:35 -0800 Subject: [PATCH] Avoid copying certain properties from behaviors This better matches what Polymer 1.x did for: * hostAttributes * listeners * properties * observers --- lib/legacy/class.js | 35 ++++++++++++++++++++++++----------- test/unit/behaviors.html | 21 +++++++++++++++++++++ 2 files changed, 45 insertions(+), 11 deletions(-) diff --git a/lib/legacy/class.js b/lib/legacy/class.js index 05ad6b2f3b..6c4fcc7fed 100644 --- a/lib/legacy/class.js +++ b/lib/legacy/class.js @@ -10,7 +10,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN import { LegacyElementMixin } from './legacy-element-mixin.js'; -const metaProps = { +const lifecycleProps = { attached: true, detached: true, ready: true, @@ -18,18 +18,31 @@ const metaProps = { beforeRegister: true, registered: true, attributeChanged: true, + listeners: true, + hostAttributes: true }; -const excludeProps = Object.assign({ +const excludeOnInfo = { + attached: true, + detached: true, + ready: true, + created: true, + beforeRegister: true, + registered: true, + attributeChanged: true, behaviors: true -}, metaProps); +}; -const lifecycleProps = Object.assign({ +const excludeOnBehaviors = Object.assign({ listeners: true, - hostAttributes: true -}, metaProps); + hostAttributes: true, + properties: true, + observers: true, +}, excludeOnInfo); + + -function copyProperties(source, target) { +function copyProperties(source, target, excludeProps) { for (let p in source) { // NOTE: cannot copy `excludeProps` methods onto prototype at least because // `super.ready` must be called and is not included in the user fn. @@ -93,12 +106,12 @@ export function mixinBehaviors(behaviors, klass) { // (again same as 1.x) function applyBehaviors(proto, behaviors, lifecycle) { for (let i=0; i @@ -434,6 +441,12 @@ + + + +