@@ -97,27 +97,32 @@ export function proxyHostElement(elm: d.HostElement, cstr: d.ComponentConstructo
97
97
enumerable : true ,
98
98
} ) ;
99
99
100
- // instance
101
- Object . defineProperty ( ( cstr as any ) . prototype , memberName , {
102
- get : function ( this : any ) {
103
- if ( origGetter && attrPropVal === undefined && ! getValue ( this , memberName ) ) {
104
- // if the initial value comes from an instance getter
105
- // the element will never have the value set. So let's do that now.
106
- setValue ( this , memberName , origGetter . apply ( this ) , cmpMeta ) ;
107
- }
108
-
109
- // if we have a parsed value from an attribute / or userland prop use that first.
110
- // otherwise if we have a getter already applied, use that.
111
- const ref = getHostRef ( this ) ;
112
- return ref . $instanceValues$ ?. get ( memberName ) !== undefined
113
- ? ref . $instanceValues$ ?. get ( memberName )
114
- : origGetter
115
- ? origGetter . apply ( this )
116
- : getValue ( this , memberName ) ;
117
- } ,
118
- configurable : true ,
119
- enumerable : true ,
120
- } ) ;
100
+ if ( ! ( cstr as any ) . prototype . __stencilAugmented ) {
101
+ // instance prototype
102
+ Object . defineProperty ( ( cstr as any ) . prototype , memberName , {
103
+ get : function ( this : any ) {
104
+ const ref = getHostRef ( this ) ;
105
+ // incoming value from a attr / prop?
106
+ const attrPropVal = ref . $instanceValues$ ?. get ( memberName ) ;
107
+
108
+ if ( origGetter && attrPropVal === undefined && ! getValue ( this , memberName ) ) {
109
+ // if the initial value comes from an instance getter
110
+ // the element will never have the value set. So let's do that now.
111
+ setValue ( this , memberName , origGetter . apply ( this ) , cmpMeta ) ;
112
+ }
113
+
114
+ // if we have a parsed value from an attribute / or userland prop use that first.
115
+ // otherwise if we have a getter already applied, use that.
116
+ return attrPropVal !== undefined
117
+ ? attrPropVal
118
+ : origGetter
119
+ ? origGetter . apply ( this )
120
+ : getValue ( this , memberName ) ;
121
+ } ,
122
+ configurable : true ,
123
+ enumerable : true ,
124
+ } ) ;
125
+ }
121
126
} else if ( memberFlags & MEMBER_FLAGS . Method ) {
122
127
Object . defineProperty ( elm , memberName , {
123
128
value ( this : d . HostElement , ...args : any [ ] ) {
@@ -131,6 +136,8 @@ export function proxyHostElement(elm: d.HostElement, cstr: d.ComponentConstructo
131
136
} ) ;
132
137
}
133
138
} ) ;
139
+ // instance prototype should only be processed once
140
+ ( cstr as any ) . prototype . __stencilAugmented = true ;
134
141
}
135
142
}
136
143
0 commit comments