Explorar el Código

fix leftoverprops with processScopedUiProps

Adam Shaw hace 7 años
padre
commit
dbb90be8ee
Se han modificado 1 ficheros con 13 adiciones y 2 borrados
  1. 13 2
      src/component/event-ui.ts

+ 13 - 2
src/component/event-ui.ts

@@ -70,16 +70,27 @@ export function processUnscopedUiProps(rawProps: UnscopedEventUiInput, calendar:
 
 export function processScopedUiProps(prefix: string, rawScoped: any, calendar: Calendar, leftovers?): EventUi {
   let rawUnscoped = {} as any
+  let wasFound = {} as any
 
   for (let key in UNSCOPED_EVENT_UI_PROPS) {
-    rawUnscoped[key] = rawScoped[prefix + capitaliseFirstLetter(key)]
+    let scopedKey = prefix + capitaliseFirstLetter(key)
+    rawUnscoped[key] = rawScoped[scopedKey]
+    wasFound[scopedKey] = true
   }
 
   if (prefix === 'event') {
     rawUnscoped.editable = rawScoped.editable // special case. there is no 'eventEditable', just 'editable'
   }
 
-  return processUnscopedUiProps(rawUnscoped, calendar, leftovers)
+  if (leftovers) {
+    for (let key in rawScoped) {
+      if (!wasFound[key]) {
+        leftovers[key] = rawScoped[key]
+      }
+    }
+  }
+
+  return processUnscopedUiProps(rawUnscoped, calendar)
 }
 
 const EMPTY_EVENT_UI: EventUi = {