File tree 2 files changed +22
-11
lines changed
packages/@posva/vuefire-core
2 files changed +22
-11
lines changed Original file line number Diff line number Diff line change @@ -180,4 +180,20 @@ describe('Firestore utils', () => {
180
180
'arr.2' : docRef ,
181
181
} )
182
182
} )
183
+
184
+ it ( 'keeps non enumerable properties' , ( ) => {
185
+ const obj = { }
186
+ Object . defineProperty ( obj , 'bar' , {
187
+ value : 'foo' ,
188
+ enumerable : false ,
189
+ } )
190
+ const [ noRefsDoc , refs ] = extractRefs ( obj , undefined , { } )
191
+ expect ( Object . getOwnPropertyDescriptor ( noRefsDoc , 'bar' ) ) . toEqual ( {
192
+ value : 'foo' ,
193
+ enumerable : false ,
194
+ configurable : false ,
195
+ writable : false ,
196
+ } )
197
+ expect ( refs ) . toEqual ( { } )
198
+ } )
183
199
} )
Original file line number Diff line number Diff line change @@ -42,17 +42,12 @@ export function extractRefs(
42
42
const [ data , refs ] = result
43
43
// Add all properties that are not enumerable (not visible in the for loop)
44
44
// getOwnPropertyDescriptors does not exist on IE
45
- // Object.getOwnPropertyNames(doc).forEach(propertyName => {
46
- // const descriptor = Object.getOwnPropertyDescriptor(doc, propertyName)
47
- // if (descriptor && !descriptor.enumerable) {
48
- // Object.defineProperty(data, propertyName, descriptor)
49
- // }
50
- // })
51
- // TODO: add test for the code above and remove this one
52
- const idDescriptor = Object . getOwnPropertyDescriptor ( doc , 'id' )
53
- if ( idDescriptor && ! idDescriptor . enumerable ) {
54
- Object . defineProperty ( data , 'id' , idDescriptor )
55
- }
45
+ Object . getOwnPropertyNames ( doc ) . forEach ( propertyName => {
46
+ const descriptor = Object . getOwnPropertyDescriptor ( doc , propertyName )
47
+ if ( descriptor && ! descriptor . enumerable ) {
48
+ Object . defineProperty ( data , propertyName , descriptor )
49
+ }
50
+ } )
56
51
57
52
// recursively traverse doc to copy values and extract references
58
53
for ( const key in doc ) {
You can’t perform that action at this time.
0 commit comments