Browse Source

Don't touch getters when initializing interceptors

Caleb Porzio 3 years ago
parent
commit
0898225972
1 changed files with 4 additions and 1 deletions
  1. 4 1
      packages/alpinejs/src/interceptor.js

+ 4 - 1
packages/alpinejs/src/interceptor.js

@@ -5,7 +5,10 @@ export function initInterceptors(data) {
     let isObject = val => typeof val === 'object' && !Array.isArray(val) && val !== null
     let isObject = val => typeof val === 'object' && !Array.isArray(val) && val !== null
 
 
     let recurse = (obj, basePath = '') => {
     let recurse = (obj, basePath = '') => {
-        Object.entries(obj).forEach(([key, value]) => {
+        Object.entries(Object.getOwnPropertyDescriptors(obj)).forEach(([key, { value, enumerable }]) => {
+            if (enumerable === false) return
+            if (value === undefined) return
+
             let path = basePath === '' ? key : `${basePath}.${key}`
             let path = basePath === '' ? key : `${basePath}.${key}`
 
 
             if (typeof value === 'object' && value !== null && value._x_interceptor) {
             if (typeof value === 'object' && value !== null && value._x_interceptor) {