Fix bug 872682 - Merge change "Remove obsolete componentFromString method reference" from upstream. r=lightsofapollo
authorPhilipp Kewisch <mozilla@kewis.ch>
Wed, 15 May 2013 21:12:43 +0200
changeset 15620 6e01f4b75f74fe070b14d7bda9753d154b4969fa
parent 15619 e67cfca5b6c0af3bc213dfda2cd5446e2fa7e8c3
child 15621 fb2c4f994f23910564b6ebe2e17bf5c1566127e1
push id942
push userbugzilla@standard8.plus.com
push dateMon, 05 Aug 2013 19:15:38 +0000
treeherdercomm-beta@0e1a1c4a9f0c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslightsofapollo
bugs872682
Fix bug 872682 - Merge change "Remove obsolete componentFromString method reference" from upstream. r=lightsofapollo
calendar/base/modules/ical.js
--- a/calendar/base/modules/ical.js
+++ b/calendar/base/modules/ical.js
@@ -2810,38 +2810,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.
      */