Skip to content

Commit

Permalink
Merge pull request #5464 from Polymer/copy-properties
Browse files Browse the repository at this point in the history
Allow `Polymer({})` calls with ES6 class
  • Loading branch information
dfreedm authored Jan 29, 2019
2 parents 038af2a + 3ff4ed1 commit c22b87c
Show file tree
Hide file tree
Showing 5 changed files with 735 additions and 940 deletions.
27 changes: 15 additions & 12 deletions lib/legacy/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,21 @@ const excludeOnBehaviors = Object.assign({

function copyProperties(source, target, excludeProps) {
const noAccessors = source._noAccessors;
for (let p in source) {
if (!(p in excludeProps)) {
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);
}
const propertyNames = Object.getOwnPropertyNames(source);
for (let i = 0; i < propertyNames.length; i++) {
let p = propertyNames[i];
if (p in excludeProps) {
continue;
}
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);
}
}
}
Expand Down
Loading

0 comments on commit c22b87c

Please sign in to comment.