Fix bug 872682 - Merge change "Remove obsolete componentFromString method reference" from upstream. r=lightsofapollo,a=philipp
authorPhilipp Kewisch <mozilla@kewis.ch>
Wed, 15 May 2013 21:12:43 +0200
changeset 15534 4399d1d6780a2a7acffb6be361ee278ce6d9e5a1
parent 15533 87f38360d9888042c7eab29aa274e377fb8c7e4d
child 15535 4037e43679e8058039ee641f4aeeb2d47a792b55
push id920
push userbugzilla@standard8.plus.com
push dateMon, 24 Jun 2013 19:03:14 +0000
treeherdercomm-beta@936bfe9d120b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslightsofapollo, philipp
bugs872682
Fix bug 872682 - Merge change "Remove obsolete componentFromString method reference" from upstream. r=lightsofapollo,a=philipp
calendar/base/modules/ical.js
--- a/calendar/base/modules/ical.js
+++ b/calendar/base/modules/ical.js
@@ -2777,38 +2777,49 @@ ICAL.Binary = (function() {
 
     icalclass: "icaltimezone",
 
     fromData: function fromData(aData) {
       this.expandedUntilYear = 0;
       this.changes = [];
 
       if (aData instanceof ICAL.Component) {
+        // Either a component is passed directly
         this.component = aData;
-        this.tzid = this.component.getFirstPropertyValue('tzid');
-        return null;
-      }
-
-      for (var key in OPTIONS) {
-        var prop = OPTIONS[key];
-        if (aData && prop in aData) {
-          this[prop] = aData[prop];
+      } else {
+        // Otherwise the component may be in the data object
+        if (aData && "component" in aData) {
+          if (typeof aData.component == "string") {
+            // If a string was passed, parse it as a component
+            var icalendar = ICAL.parse(aData.component);
+            this.component = new ICAL.Component(icalendar[1]);
+          } else if (aData.component instanceof ICAL.Component) {
+            // If it was a component already, then just set it
+            this.component = aData.component;
+          } else {
+            // Otherwise just null out the component
+            this.component = null;
+          }
         }
-      }
-
-      if (aData && "component" in aData) {
-        if (typeof aData.component == "string") {
-          let icalendar = ICAL.parse(aData.component);
-          this.component = new ICAL.Component(icalendar[1]);
-        } else {
-          this.component = aData.component;
+
+        // Copy remaining passed properties
+        for (var key in OPTIONS) {
+          var prop = OPTIONS[key];
+          if (aData && prop in aData) {
+            this[prop] = aData[prop];
+          }
         }
-      } else {
-        this.component = null;
-      }
+      }
+
+      // If we have a component but no TZID, attempt to get it from the
+      // component's properties.
+      if (this.component instanceof ICAL.Component && !this.tzid) {
+        this.tzid = this.component.getFirstPropertyValue('tzid');
+      }
+
       return this;
     },
 
     /**
      * Finds the utcOffset the given time would occur in this timezone.
      *
      * @return {Number} utc offset in seconds.
      */