Adam Shaw %!s(int64=8) %!d(string=hai) anos
pai
achega
87b3955780

+ 2 - 2
src/Calendar.ts

@@ -108,7 +108,7 @@ export default class Calendar {
 
     if (Array.isArray(triggerInfo)) {
       args = triggerInfo
-    } else if (typeof triggerInfo === 'object') {
+    } else if (typeof triggerInfo === 'object' && triggerInfo) { // non-null object
       context = triggerInfo.context
       args = triggerInfo.args
     }
@@ -151,7 +151,7 @@ export default class Calendar {
         newOptionHash[name] = value
         this.optionsManager.add(newOptionHash)
       }
-    } else if (typeof name === 'object') { // compound setter with object input
+    } else if (typeof name === 'object' && name) { // compound setter with object input (non-null)
       this.optionsManager.add(name)
     }
   }

+ 1 - 1
src/Constraints.ts

@@ -171,7 +171,7 @@ export default class Constraints {
 
     if (constraintVal === 'businessHours') {
       return this.buildCurrentBusinessFootprints(isAllDay)
-    } else if (typeof constraintVal === 'object') {
+    } else if (typeof constraintVal === 'object' && constraintVal) { // non-null object
       eventInstances = this.parseEventDefToInstances(constraintVal) // handles recurring events
 
       if (!eventInstances) { // invalid input. fallback to parsing footprint directly

+ 1 - 1
src/common/ListenerMixin.ts

@@ -36,7 +36,7 @@ export default class ListenerMixin extends Mixin implements ListenerInterface {
     })
   */
   listenTo(other, arg, callback?) {
-    if (typeof arg === 'object') { // given dictionary of callbacks
+    if (typeof arg === 'object' && arg) { // given dictionary of callbacks (non-null)
       for (let eventName in arg) {
         if (arg.hasOwnProperty(eventName)) {
           this.listenTo(other, eventName, arg[eventName])

+ 1 - 1
src/common/Model.ts

@@ -121,7 +121,7 @@ export default class Model extends Class {
       // if an object, don't check equality, because might have been mutated internally.
       // TODO: eventually enforce immutability.
       if (
-        typeof val === 'object' ||
+        (typeof val === 'object' && val) || // non-null object
         val !== this._props[name]
       ) {
         changedProps[name] = val

+ 1 - 1
src/component/interactions/ExternalDropping.ts

@@ -212,7 +212,7 @@ function getDraggedElMeta(el) {
   eventProps = el.data(prefix + 'event') || null
 
   if (eventProps) {
-    if (typeof eventProps === 'object') {
+    if (typeof eventProps === 'object' && eventProps) { // non-null object
       eventProps = assignTo({}, eventProps) // make a copy
     } else { // something like 1 or true. still signal event creation
       eventProps = {}

+ 1 - 1
src/models/BusinessHourGenerator.ts

@@ -55,7 +55,7 @@ export default class BusinessHourGenerator {
     } else if (Array.isArray(rawComplexDef)) {
       rawDefs = rawComplexDef
       requireDow = true // every sub-definition NEEDS a day-of-week
-    } else if (typeof rawComplexDef === 'object') {
+    } else if (typeof rawComplexDef === 'object' && rawComplexDef) { // non-null object
       rawDefs = [ rawComplexDef ]
     }
 

+ 1 - 1
src/models/event-source/EventSource.ts

@@ -51,7 +51,7 @@ export default class EventSource extends Class {
   static parse(rawInput, calendar) {
     let source = new this(calendar)
 
-    if (typeof rawInput === 'object') {
+    if (typeof rawInput === 'object' && rawInput) { // non-null object
       if (source.applyProps(rawInput)) {
         return source
       }

+ 1 - 1
src/theme/Theme.ts

@@ -33,7 +33,7 @@ export default class Theme {
     let iconClassesCopy
     let buttonName
 
-    if (typeof iconOverrideHash === 'object') {
+    if (typeof iconOverrideHash === 'object' && iconOverrideHash) { // non-null object
       iconClassesCopy = assignTo({}, this.iconClasses)
 
       for (buttonName in iconOverrideHash) {

+ 2 - 2
src/util.ts

@@ -543,7 +543,7 @@ export function computeDurationGreatestUnit(duration, durationInput) {
   let unit = computeGreatestUnit(duration)
 
   // prevent days:7 from being interpreted as a week
-  if (unit === 'week' && typeof durationInput === 'object' && durationInput.days) {
+  if (unit === 'week' && typeof durationInput === 'object' && durationInput && durationInput.days) { // non-null object
     unit = 'day'
   }
 
@@ -684,7 +684,7 @@ export function mergeProps(propObjs, complexProps?) {
       for (j = propObjs.length - 1; j >= 0; j--) {
         val = propObjs[j][name]
 
-        if (typeof val === 'object') {
+        if (typeof val === 'object' && val) { // non-null object
           complexObjs.unshift(val)
         } else if (val !== undefined) {
           dest[name] = val // if there were no objects, this value will be used