Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1624)

Unified Diff: chrome/browser/resources/md_history/list_container.js

Issue 2230003002: MD History: Add lazy-render element for simple lazy initialization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/md_history/list_container.js
diff --git a/chrome/browser/resources/md_history/list_container.js b/chrome/browser/resources/md_history/list_container.js
index a0ba4c3e9fb728b37f70b37881a03b2f47aad837..e2e5c67d9841a591bfb115daabc835d27d9af8a3 100644
--- a/chrome/browser/resources/md_history/list_container.js
+++ b/chrome/browser/resources/md_history/list_container.js
@@ -66,8 +66,9 @@ Polymer({
}
// Close any open dialog if a new query is initiated.
- if (!incremental && this.$.dialog.open)
- this.$.dialog.close();
+ var dialog = this.$.dialog.getIfExists();
+ if (!incremental && dialog && dialog.open)
+ dialog.close();
this.set('queryState.querying', true);
this.set('queryState.incremental', incremental);
@@ -97,8 +98,9 @@ Polymer({
deleteSelectedWithPrompt: function() {
if (!loadTimeData.getBoolean('allowDeletingHistory'))
return;
-
- this.$.dialog.showModal();
+ this.$.dialog.get().then(function(dialog) {
+ dialog.showModal();
+ });
},
/**
@@ -141,12 +143,14 @@ Polymer({
/** @private */
onDialogConfirmTap_: function() {
this.getSelectedList_().deleteSelected();
- this.$.dialog.close();
+ var dialog = assert(this.$.dialog.getIfExists());
+ dialog.close();
},
/** @private */
onDialogCancelTap_: function() {
- this.$.dialog.close();
+ var dialog = assert(this.$.dialog.getIfExists());
+ dialog.close();
},
/**
@@ -154,31 +158,36 @@ Polymer({
* @private
*/
closeMenu_: function() {
- /** @type {CrSharedMenuElement} */(this.$.sharedMenu).closeMenu();
+ var menu = this.$.sharedMenu.getIfExists();
+ if (menu)
+ menu.closeMenu();
},
/**
* Opens the overflow menu unless the menu is already open and the same button
* is pressed.
* @param {{detail: {item: !HistoryEntry, target: !HTMLElement}}} e
+ * @return {Promise<Element>}
* @private
*/
toggleMenu_: function(e) {
var target = e.detail.target;
- /** @type {CrSharedMenuElement} */(this.$.sharedMenu).toggleMenu(
+ return this.$.sharedMenu.get().then(function(menu) {
+ /** @type {CrSharedMenuElement} */(menu).toggleMenu(
target, e.detail);
+ });
},
/** @private */
onMoreFromSiteTap_: function() {
- var menu = /** @type {CrSharedMenuElement} */(this.$.sharedMenu);
+ var menu = assert(this.$.sharedMenu.getIfExists());
this.fire('search-domain', {domain: menu.itemData.item.domain});
menu.closeMenu();
},
/** @private */
onRemoveFromHistoryTap_: function() {
- var menu = /** @type {CrSharedMenuElement} */(this.$.sharedMenu);
+ var menu = assert(this.$.sharedMenu.getIfExists());
var itemData = menu.itemData;
md_history.BrowserService.getInstance()
.deleteItems([itemData.item])

Powered by Google App Engine
This is Rietveld 408576698