Bug 824150 - Code cleanup in /mail/ and /mailnews/: Use new String methods like startsWith, endsWith, contains, remaining Services.jsm switches and querySelector use instead of NodeList calls: newsblog. r=mbanner
authorSebastian Hengst <archaeopteryx@coole-files.de>
Sat, 09 Feb 2013 20:05:22 +0100
changeset 14842 59e6970aea76a5207a7ab01b476a8fd2ce081b71
parent 14841 9e7319029574532affae61a2b6e9dc5b2453ba5d
child 14843 e89c30d54a1e8bd5ef82f0ff9d29b6a0d520c6ed
push id867
push userbugzilla@standard8.plus.com
push dateMon, 01 Apr 2013 20:44:27 +0000
treeherdercomm-beta@797726b8d244 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmbanner
bugs824150
Bug 824150 - Code cleanup in /mail/ and /mailnews/: Use new String methods like startsWith, endsWith, contains, remaining Services.jsm switches and querySelector use instead of NodeList calls: newsblog. r=mbanner
mailnews/extensions/newsblog/content/Feed.js
mailnews/extensions/newsblog/content/FeedItem.js
mailnews/extensions/newsblog/content/feed-parser.js
mailnews/extensions/newsblog/content/feed-subscriptions.js
--- a/mailnews/extensions/newsblog/content/Feed.js
+++ b/mailnews/extensions/newsblog/content/Feed.js
@@ -302,17 +302,17 @@ Feed.prototype =
 
   get quickMode ()
   {
     let ds = FeedUtils.getSubscriptionsDS(this.server);
     let quickMode = ds.GetTarget(this.resource, FeedUtils.FZ_QUICKMODE, true);
     if (quickMode)
     {
       quickMode = quickMode.QueryInterface(Ci.nsIRDFLiteral);
-      quickMode = quickMode.Value == "true" ? true : false;
+      quickMode = quickMode.Value == "true";
     }
 
     return quickMode;
   },
 
   set quickMode (aNewQuickMode)
   {
     let ds = FeedUtils.getSubscriptionsDS(this.server);
--- a/mailnews/extensions/newsblog/content/FeedItem.js
+++ b/mailnews/extensions/newsblog/content/FeedItem.js
@@ -295,17 +295,17 @@ FeedItem.prototype =
 
   writeToFolder: function()
   {
     FeedUtils.log.trace("FeedItem.writeToFolder: " + this.identity +
                         " writing to message folder " + this.feed.name);
     this.mUnicodeConverter.charset = this.characterSet;
 
     // If the sender isn't a valid email address, quote it so it looks nicer.
-    if (this.author && this.author.indexOf("@") == -1)
+    if (this.author && !this.author.contains("@"))
       this.author = "<" + this.author + ">";
 
     // Convert the title to UTF-16 before performing our HTML entity
     // replacement reg expressions.
     let title = this.title;
 
     // The subject may contain HTML entities.  Convert these to their unencoded
     // state. i.e. &amp; becomes '&'.
--- a/mailnews/extensions/newsblog/content/feed-parser.js
+++ b/mailnews/extensions/newsblog/content/feed-parser.js
@@ -74,17 +74,17 @@ FeedParser.prototype =
     }
   },
 
   parseAsRSS2: function (aFeed, aDOM)
   {
     // Get the first channel (assuming there is only one per RSS File).
     let parsedItems = new Array();
 
-    let channel = aDOM.getElementsByTagName("channel")[0];
+    let channel = aDOM.querySelector("channel");
     if (!channel)
       return aFeed.onParseError(aFeed);
 
     // Usually the empty string, unless this is RSS .90.
     let nsURI = channel.namespaceURI || "";
     FeedUtils.log.debug("FeedParser.parseAsRSS2: channel nsURI - " + nsURI);
 
     let tags = this.childrenByTagNameNS(channel, nsURI, "title");
@@ -305,17 +305,17 @@ FeedParser.prototype =
     return parsedItems;
   },
 
   parseAsAtom: function(aFeed, aDOM)
   {
     let parsedItems = new Array();
 
     // Get the first channel (assuming there is only one per Atom File).
-    let channel = aDOM.getElementsByTagName("feed")[0];
+    let channel = aDOM.querySelector("feed");
     if (!channel)
     {
       aFeed.onParseError(aFeed);
       return parsedItems;
     }
 
     let tags = this.childrenByTagNameNS(channel, FeedUtils.ATOM_03_NS, "title");
     aFeed.title = aFeed.title ||
--- a/mailnews/extensions/newsblog/content/feed-subscriptions.js
+++ b/mailnews/extensions/newsblog/content/feed-subscriptions.js
@@ -1277,17 +1277,17 @@ var FeedSubscriptions = {
  * Moves or copies a feed to another folder or account.
  * 
  * @param  int aOldFeedIndex    - index in tree of target feed item.
  * @param  int aNewParentIndex  - index in tree of target parent folder item.
  * @param  string aMoveCopy     - either "move" or "copy".
  */
   moveCopyFeed: function(aOldFeedIndex, aNewParentIndex, aMoveCopy)
   {
-    let moveFeed = aMoveCopy == "move" ? true : false;
+    let moveFeed = aMoveCopy == "move";
     let currentItem = this.mView.getItemAtIndex(aOldFeedIndex);
     if (!currentItem ||
         this.mView.getParentIndex(aOldFeedIndex) == aNewParentIndex)
       // If the new parent is the same as the current parent, then do nothing.
       return;
 
     let currentParentIndex = this.mView.getParentIndex(aOldFeedIndex);
     let currentParentItem = this.mView.getItemAtIndex(currentParentIndex);
@@ -2142,17 +2142,17 @@ var FeedSubscriptions = {
                        "subscribe-errorOpeningFile");
       Services.prompt.alert(window, null, statusReport);
       return false;
     }
     finally {
       stream.close();
     }
 
-    let body = opmlDom ? opmlDom.getElementsByTagName("body")[0] : null;
+    let body = opmlDom ? opmlDom.querySelector("body") : null;
 
     // Return if the OPML file is invalid or empty.
     if (!body || !body.childElementCount ||
       opmlDom.documentElement.tagName != "opml")
     {
       statusReport = FeedUtils.strings.formatStringFromName(
                        "subscribe-OPMLImportInvalidFile", [aFile.leafName], 1);
       Services.prompt.alert(window, null, statusReport);
@@ -2238,18 +2238,18 @@ var FeedSubscriptions = {
             // parent of feed's folder.
             // NOTE: Assume a type=rss outline must be a leaf and is not a
             // direct parent of another type=rss outline; such a structure
             // may lead to unintended nesting and inaccurate counts.
           }
 
           // Create the feed.
           let quickMode = outline.hasAttribute("fz:quickMode") ?
-                          outline.getAttribute("fz:quickMode") == "true" ?
-                          true : false : rssServer.getBoolValue("quickMode");
+                          outline.getAttribute("fz:quickMode") == "true" :
+                          rssServer.getBoolValue("quickMode");
 
           if (firstFeedInFolderQuickMode === null)
             // The summary/web page pref applies to all feeds in a folder,
             // though it is a property of an individual feed.  This can be
             // set (and is obvious) in the subscribe dialog; ensure import
             // doesn't leave mismatches if mismatched in the opml file.
             firstFeedInFolderQuickMode = quickMode;
           else