Bug 1332610 - Create Intl.DateTimeFormat in LoginManagerContextMenu.jsm lazily. r?MattN
MozReview-Commit-ID: 3FJssahmHyd
--- a/toolkit/components/passwordmgr/LoginManagerContextMenu.jsm
+++ b/toolkit/components/passwordmgr/LoginManagerContextMenu.jsm
@@ -14,18 +14,26 @@ XPCOMUtils.defineLazyModuleGetter(this,
"resource://gre/modules/LoginHelper.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "LoginManagerParent",
"resource://gre/modules/LoginManagerParent.jsm");
/*
* Password manager object for the browser contextual menu.
*/
var LoginManagerContextMenu = {
- dateAndTimeFormatter: new Intl.DateTimeFormat(undefined,
- { day: "numeric", month: "short", year: "numeric" }),
+ _dateAndTimeFormatter: null,
+
+ get dateAndTimeFormatter() {
+ if (!this._dateAndTimeFormatter) {
+ this._dateAndTimeFormatter = new Intl.DateTimeFormat(undefined,
+ { day: "numeric", month: "short", year: "numeric" });
+ }
+ return this._dateAndTimeFormatter;
+ },
+
/**
* Look for login items and add them to the contextual menu.
*
* @param {HTMLInputElement} inputElement
* The target input element of the context menu click.
* @param {xul:browser} browser
* The browser for the document the context menu was open on.
* @param {nsIURI} documentURI