Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polymer 2.x version of #5464 #5469

Merged
merged 1 commit into from
Jan 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions lib/legacy/class.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,21 @@

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
3 changes: 2 additions & 1 deletion test/runner.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@
'unit/disable-upgrade.html',
'unit/shady-unscoped-style.html',
'unit/html-tag.html',
'unit/legacy-data.html'
'unit/legacy-data.html',
// 'unit/multi-style.html'
'unit/class-properties.html'
];

function combinations(suites, flags) {
Expand Down
38 changes: 38 additions & 0 deletions test/unit/class-properties.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!doctype html>
<!--
@license
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
<meta charset="utf-8">
<script src="../../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../../web-component-tester/browser.js"></script>
<link rel="import" href="../../polymer.html">
</head>
<body>
<script>
class Example {
ready() {}
foo() {}
}
Example.prototype.is = 'x-example';

suite('Polymer function w/Class', function() {
test('Polymer call works with a class', function() {
assert.doesNotThrow(() => Polymer(Example.prototype));
});
test('methods are copied from class input', function() {
const def = customElements.get('x-example');
assert(def.prototype.ready, 'ready should be defined');
assert(def.prototype.foo, 'foo should be defined');
});
});
</script>
</body>
</html>