diff --git a/lib/legacy/class.js b/lib/legacy/class.js index 49a551c3e9..afe69ead11 100644 --- a/lib/legacy/class.js +++ b/lib/legacy/class.js @@ -30,7 +30,8 @@ const excludeOnInfo = { beforeRegister: true, registered: true, attributeChanged: true, - behaviors: true + behaviors: true, + _noAccessors: true }; const excludeOnBehaviors = Object.assign({ @@ -41,13 +42,19 @@ const excludeOnBehaviors = Object.assign({ }, excludeOnInfo); function copyProperties(source, target, excludeProps) { + const noAccessors = source._noAccessors; 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. if (!(p in excludeProps)) { - let pd = Object.getOwnPropertyDescriptor(source, p); - if (pd) { - Object.defineProperty(target, p, pd); + if (noAccessors) { + target[p] = source[p]; + } else { + let pd = Object.getOwnPropertyDescriptor(source, p); + if (pd) { + // ensure property is configurable so that a later behavior can + // re-configure it. + pd.configurable = true; + Object.defineProperty(target, p, pd); + } } } } @@ -498,6 +505,6 @@ export const Class = function(info, mixin) { LegacyElementMixin(HTMLElement); klass = GenerateClassFromInfo(info, klass, info.behaviors); // decorate klass with registration info - klass.is = info.is; + klass.is = klass.prototype.is = info.is; return klass; }; diff --git a/test/unit/behaviors.html b/test/unit/behaviors.html index 3ffe8a89fd..61de81d601 100644 --- a/test/unit/behaviors.html +++ b/test/unit/behaviors.html @@ -379,6 +379,20 @@ behaviors: [window.BehaviorA] }); + Polymer({ + is: 'no-accessors-behavior', + behaviors: [{ + _noAccessors: true, + properties: { + nug: String + }, + foo: function() {}, + bar: true + }], + _noAccessors: true, + zot: 'zot' + }); + @@ -447,6 +461,12 @@ + + + +