Ver código fonte

dont use Object.assign (for IE11)

Adam Shaw 7 anos atrás
pai
commit
24aa700001

+ 5 - 4
src/Calendar.ts

@@ -30,6 +30,7 @@ import EventDragging from './interactions/EventDragging'
 import { buildViewSpecs, ViewSpecHash, ViewSpec } from './structs/view-spec'
 import { PluginSystem, PluginDef } from './plugin-system'
 import CalendarComponent from './CalendarComponent'
+import { __assign } from 'tslib'
 
 
 export interface DateClickApi extends DatePointApi {
@@ -937,10 +938,10 @@ export default class Calendar {
     let props = {} as DatePointApi
 
     for (let transform of this.pluginSystem.hooks.datePointTransforms) {
-      Object.assign(props, transform(dateSpan, this))
+      __assign(props, transform(dateSpan, this))
     }
 
-    Object.assign(props, buildDatePointApi(dateSpan, this.dateEnv))
+    __assign(props, buildDatePointApi(dateSpan, this.dateEnv))
 
     return props
   }
@@ -950,10 +951,10 @@ export default class Calendar {
     let props = {} as DateSpanApi
 
     for (let transform of this.pluginSystem.hooks.dateSpanTransforms) {
-      Object.assign(props, transform(dateSpan, this))
+      __assign(props, transform(dateSpan, this))
     }
 
-    Object.assign(props, buildDateSpanApi(dateSpan, this.dateEnv))
+    __assign(props, buildDateSpanApi(dateSpan, this.dateEnv))
 
     return props
   }

+ 2 - 1
src/CalendarComponent.ts

@@ -15,6 +15,7 @@ import { diffWholeDays } from './datelib/marker'
 import { memoizeRendering } from './component/memoized-rendering'
 import { CalendarState } from './reducers/types'
 import { ViewPropsTransformerClass } from './plugin-system'
+import { __assign } from 'tslib'
 
 export interface CalendarComponentProps extends CalendarState {
   viewSpec: ViewSpec
@@ -199,7 +200,7 @@ export default class CalendarComponent extends Component<CalendarComponentProps>
     let transformers = this.buildViewPropTransformers(this.calendar.pluginSystem.hooks.viewPropsTransformers)
 
     for (let transformer of transformers) {
-      Object.assign(
+      __assign(
         viewProps,
         transformer.transform(viewProps, viewSpec, props, view)
       )

+ 4 - 3
src/View.ts

@@ -13,6 +13,7 @@ import { sliceEventStore, EventRenderRange } from './component/event-rendering'
 import { DateSpan } from './structs/date-span'
 import { EventInteractionState } from './interactions/event-interaction-state'
 import { memoizeRendering } from './component/memoized-rendering'
+import { __assign } from 'tslib'
 
 export interface ViewProps {
   dateProfile: DateProfile
@@ -375,7 +376,7 @@ export default abstract class View extends DateComponent<ViewProps> {
   addScroll(scroll) {
     let queuedScroll = this.queuedScroll || (this.queuedScroll = {})
 
-    Object.assign(queuedScroll, scroll)
+    __assign(queuedScroll, scroll)
   }
 
 
@@ -394,7 +395,7 @@ export default abstract class View extends DateComponent<ViewProps> {
     let scroll = {} as any
 
     if (this.props.dateProfile) { // dates rendered yet?
-      Object.assign(scroll, this.queryDateScroll())
+      __assign(scroll, this.queryDateScroll())
     }
 
     return scroll
@@ -407,7 +408,7 @@ export default abstract class View extends DateComponent<ViewProps> {
       delete scroll.isDateInit
 
       if (this.props.dateProfile) { // dates rendered yet?
-        Object.assign(scroll, this.computeInitialDateScroll())
+        __assign(scroll, this.computeInitialDateScroll())
       }
     }
 

+ 2 - 1
src/component/event-splitting.ts

@@ -5,6 +5,7 @@ import { mapHash } from '../util/object'
 import { memoize } from '../util/memoize'
 import { EventUiHash, EventUi, combineEventUis } from './event-ui'
 import { DateSpan } from '../structs/date-span'
+import { __assign } from 'tslib'
 
 export interface SplittableProps {
   businessHours: EventStore | null // is this really allowed to be null?
@@ -185,7 +186,7 @@ function buildEventUiForKey(allUi: EventUi | null, eventUiForKey: EventUi | null
   }
 
   if (individualUi) {
-    Object.assign(stuff, individualUi)
+    __assign(stuff, individualUi)
   }
 
   return stuff

+ 2 - 1
src/event-sources/json-feed-event-source.ts

@@ -2,6 +2,7 @@ import * as request from 'superagent'
 import Calendar from '../Calendar'
 import { registerEventSourceDef } from '../structs/event-source'
 import { DateRange } from '../datelib/date-range'
+import { __assign } from 'tslib'
 
 interface JsonFeedMeta {
   url: string
@@ -99,7 +100,7 @@ function buildRequestParams(meta: JsonFeedMeta, range: DateRange, calendar: Cale
     customRequestParams = meta.extraData || {}
   }
 
-  Object.assign(params, customRequestParams)
+  __assign(params, customRequestParams)
 
   params[startParam] = dateEnv.formatIso(range.start)
   params[endParam] = dateEnv.formatIso(range.end)

+ 2 - 1
src/interactions-external/ExternalElementDragging.ts

@@ -14,6 +14,7 @@ import { elementMatches } from '../util/dom-manip'
 import { enableCursor, disableCursor } from '../util/misc'
 import { isInteractionValid } from '../validation'
 import View from '../View'
+import { __assign } from 'tslib'
 
 export type DragMetaGenerator = DragMetaInput | ((el: HTMLElement) => DragMetaInput)
 
@@ -207,7 +208,7 @@ function computeEventForDateSpan(dateSpan: DateSpan, dragMeta: DragMeta, calenda
   let defProps = { ...dragMeta.leftoverProps }
 
   for (let transform of calendar.pluginSystem.hooks.externalDefTransforms) {
-    Object.assign(defProps, transform(dateSpan, dragMeta))
+    __assign(defProps, transform(dateSpan, dragMeta))
   }
 
   let def = parseEventDef(

+ 2 - 1
src/interactions/DateSelecting.ts

@@ -4,6 +4,7 @@ import HitDragging, { Hit } from './HitDragging'
 import { DateSpan } from '../structs/date-span'
 import { PointerDragEvent } from '../dnd/PointerDragging'
 import FeaturefulElementDragging from '../dnd/FeaturefulElementDragging'
+import { __assign } from 'tslib'
 
 /*
 Tracks when the user selects a portion of time of a component,
@@ -128,7 +129,7 @@ function joinHitsIntoSelection(hit0: Hit, hit1: Hit, dateSelectionTransformers:
     if (res === false) {
       return null
     } else if (res) {
-      Object.assign(props, res)
+      __assign(props, res)
     }
   }
 

+ 2 - 1
src/interactions/EventResizing.ts

@@ -11,6 +11,7 @@ import EventApi from '../api/EventApi'
 import { EventRenderRange, getElSeg } from '../component/event-rendering'
 import { createDuration } from '../datelib/duration'
 import { EventInteractionState } from './event-interaction-state'
+import { __assign } from 'tslib'
 
 export default class EventDragging {
 
@@ -228,7 +229,7 @@ function computeMutation(hit0: Hit, hit1: Hit, isFromStart: boolean, instanceRan
     if (res === false) {
       return null
     } else if (res) {
-      Object.assign(props, res)
+      __assign(props, res)
     }
   }
 

+ 6 - 5
src/structs/event-mutation.ts

@@ -43,7 +43,6 @@ export type eventDefMutationApplier = (eventDef: EventDef, mutation: EventMutati
 
 
 function applyMutationToEventDef(eventDef: EventDef, eventConfig: EventUi, mutation: EventMutation, appliers: eventDefMutationApplier[], calendar: Calendar): EventDef {
-  let copy = { ...eventDef }
   let standardProps = mutation.standardProps || {}
 
   // if hasEnd has not been specified, guess a good value based on deltas.
@@ -56,12 +55,14 @@ function applyMutationToEventDef(eventDef: EventDef, eventConfig: EventUi, mutat
       eventConfig.durationEditable ? mutation.endDelta : null
     )
   ) {
-    standardProps.hasEnd = true
+    standardProps.hasEnd = true // TODO: is this mutation okay?
   }
 
-  Object.assign(copy, standardProps, {
-    ui: { ...copy.ui, ...standardProps.ui } // the only prop we want to recursively overlay
-  })
+  let copy = {
+    ...eventDef,
+    ...standardProps,
+    ui: { ...eventDef.ui, ...standardProps.ui } // the only prop we want to recursively overlay
+  }
 
   if (mutation.extendedProps) {
     copy.extendedProps = { ...copy.extendedProps, ...mutation.extendedProps }

+ 2 - 1
src/structs/event.ts

@@ -6,6 +6,7 @@ import { startOfDay } from '../datelib/marker'
 import { parseRecurring } from './recurring-event'
 import { Duration } from '../datelib/duration'
 import { UnscopedEventUiInput, EventUi, processUnscopedUiProps } from '../component/event-ui'
+import { __assign } from 'tslib'
 
 /*
 Utils for parsing event-input data. Each util parses a subset of the event-input's data.
@@ -140,7 +141,7 @@ export function parseEventDef(raw: EventNonDateInput, sourceId: string, allDay:
     leftovers = newLeftovers
   }
 
-  def.extendedProps = Object.assign(leftovers, def.extendedProps || {})
+  def.extendedProps = __assign(leftovers, def.extendedProps || {})
 
   // help out EventApi from having user modify props
   Object.freeze(def.ui.classNames)