File tree Expand file tree Collapse file tree 3 files changed +55
-13
lines changed Expand file tree Collapse file tree 3 files changed +55
-13
lines changed Original file line number Diff line number Diff line change 47
47
48
48
function copyProperties ( source , target , excludeProps ) {
49
49
const noAccessors = source . _noAccessors ;
50
- for ( let p in source ) {
51
- if ( ! ( p in excludeProps ) ) {
52
- if ( noAccessors ) {
53
- target [ p ] = source [ p ] ;
54
- } else {
55
- let pd = Object . getOwnPropertyDescriptor ( source , p ) ;
56
- if ( pd ) {
57
- // ensure property is configurable so that a later behavior can
58
- // re-configure it.
59
- pd . configurable = true ;
60
- Object . defineProperty ( target , p , pd ) ;
61
- }
50
+ const propertyNames = Object . getOwnPropertyNames ( source ) ;
51
+ for ( let i = 0 ; i < propertyNames . length ; i ++ ) {
52
+ let p = propertyNames [ i ] ;
53
+ if ( p in excludeProps ) {
54
+ continue ;
55
+ }
56
+ if ( noAccessors ) {
57
+ target [ p ] = source [ p ] ;
58
+ } else {
59
+ let pd = Object . getOwnPropertyDescriptor ( source , p ) ;
60
+ if ( pd ) {
61
+ // ensure property is configurable so that a later behavior can
62
+ // re-configure it.
63
+ pd . configurable = true ;
64
+ Object . defineProperty ( target , p , pd ) ;
62
65
}
63
66
}
64
67
}
Original file line number Diff line number Diff line change 82
82
'unit/disable-upgrade.html' ,
83
83
'unit/shady-unscoped-style.html' ,
84
84
'unit/html-tag.html' ,
85
- 'unit/legacy-data.html'
85
+ 'unit/legacy-data.html' ,
86
86
// 'unit/multi-style.html'
87
+ 'unit/class-properties.html'
87
88
] ;
88
89
89
90
function combinations ( suites , flags ) {
Original file line number Diff line number Diff line change
1
+ <!doctype html>
2
+ <!--
3
+ @license
4
+ Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
5
+ This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
6
+ The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
7
+ The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
8
+ Code distributed by Google as part of the polymer project is also
9
+ subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
10
+ -->
11
+ < html >
12
+ < head >
13
+ < meta charset ="utf-8 ">
14
+ < script src ="../../../webcomponentsjs/webcomponents-lite.js "> </ script >
15
+ < script src ="../../../web-component-tester/browser.js "> </ script >
16
+ < link rel ="import " href ="../../polymer.html ">
17
+ </ head >
18
+ < body >
19
+ < script >
20
+ class Example {
21
+ ready ( ) { }
22
+ foo ( ) { }
23
+ }
24
+ Example . prototype . is = 'x-example' ;
25
+
26
+ suite ( 'Polymer function w/Class' , function ( ) {
27
+ test ( 'Polymer call works with a class' , function ( ) {
28
+ assert . doesNotThrow ( ( ) => Polymer ( Example . prototype ) ) ;
29
+ } ) ;
30
+ test ( 'methods are copied from class input' , function ( ) {
31
+ const def = customElements . get ( 'x-example' ) ;
32
+ assert ( def . prototype . ready , 'ready should be defined' ) ;
33
+ assert ( def . prototype . foo , 'foo should be defined' ) ;
34
+ } ) ;
35
+ } ) ;
36
+ </ script >
37
+ </ body >
38
+ </ html >
You can’t perform that action at this time.
0 commit comments