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

Unified Diff: chrome/browser/resources/md_history/app.crisper.js

Issue 2341923005: MD WebUI: Make cr-lazy-render get() synchronous (Closed)
Patch Set: Simplify test more Created 4 years, 3 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/app.crisper.js
diff --git a/chrome/browser/resources/md_history/app.crisper.js b/chrome/browser/resources/md_history/app.crisper.js
index d02d330f3779262509a92ef2d5c7b80f761bb391..9225264aec1be9322258ae0c272bcd5fe8997bce 100644
--- a/chrome/browser/resources/md_history/app.crisper.js
+++ b/chrome/browser/resources/md_history/app.crisper.js
@@ -5387,37 +5387,28 @@ Polymer({
is: 'cr-lazy-render',
"extends": 'template',
behaviors: [ Polymer.Templatizer ],
- _renderPromise: null,
- _child: null,
+ child_: null,
get: function() {
- if (!this._renderPromise) {
- this._renderPromise = new Promise(function(resolve) {
- this._debounceTemplate(function() {
- this._render();
- this._renderPromise = null;
- resolve(this.getIfExists());
- }.bind(this));
- }.bind(this));
- }
- return this._renderPromise;
+ if (!this.child_) this.render_();
+ return this.child_;
},
getIfExists: function() {
- return this._child;
+ return this.child_;
},
- _render: function() {
+ render_: function() {
if (!this.ctor) this.templatize(this);
var parentNode = this.parentNode;
- if (parentNode && !this._child) {
+ if (parentNode && !this.child_) {
var instance = this.stamp({});
- this._child = instance.root.querySelector('*');
+ this.child_ = instance.root.firstElementChild;
parentNode.insertBefore(instance.root, this);
}
},
_forwardParentProp: function(prop, value) {
- if (this._child) this._child._templateInstance[prop] = value;
+ if (this.child_) this.child_._templateInstance[prop] = value;
},
_forwardParentPath: function(path, value) {
- if (this._child) this._child._templateInstance.notifyPath(path, value, true);
+ if (this.child_) this.child_._templateInstance.notifyPath(path, value, true);
}
});
@@ -6138,10 +6129,9 @@ Polymer({
this.searchTerm = event.detail;
},
onInfoButtonTap_: function() {
- this.$.syncNotice.get().then(function(dropdown) {
- dropdown.positionTarget = this.$$('#info-button-icon');
- if (dropdown.style.display == 'none') dropdown.open();
- }.bind(this));
+ var dropdown = this.$.syncNotice.get();
+ dropdown.positionTarget = this.$$('#info-button-icon');
+ if (dropdown.style.display == 'none') dropdown.open();
},
onClearSelectionTap_: function() {
this.fire('unselect-all');
@@ -8131,9 +8121,7 @@ Polymer({
var browserService = md_history.BrowserService.getInstance();
browserService.recordAction('RemoveSelected');
if (this.queryState.searchTerm != '') browserService.recordAction('SearchResultRemove');
- this.$.dialog.get().then(function(dialog) {
- dialog.showModal();
- });
+ this.$.dialog.get().showModal();
},
groupedRangeChanged_: function(range, oldRange) {
this.selectedPage_ = range == HistoryRange.ALL_TIME ? 'infinite-list' : 'grouped-list';
@@ -8172,9 +8160,8 @@ Polymer({
},
toggleMenu_: function(e) {
var target = e.detail.target;
- return this.$.sharedMenu.get().then(function(menu) {
- menu.toggleMenu(target, e.detail);
- });
+ var menu = this.$.sharedMenu.get();
+ menu.toggleMenu(target, e.detail);
},
onMoreFromSiteTap_: function() {
md_history.BrowserService.getInstance().recordAction('EntryMenuShowMoreFromSite');
@@ -8360,12 +8347,11 @@ Polymer({
if (menu) menu.closeMenu();
},
onToggleMenu_: function(e) {
- this.$.menu.get().then(function(menu) {
- menu.toggleMenu(e.detail.target, e.detail.tag);
- if (menu.menuOpen) {
- md_history.BrowserService.getInstance().recordHistogram(SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.SHOW_SESSION_MENU, SyncedTabsHistogram.LIMIT);
- }
- });
+ var menu = this.$.menu.get();
+ menu.toggleMenu(e.detail.target, e.detail.tag);
+ if (menu.menuOpen) {
+ md_history.BrowserService.getInstance().recordHistogram(SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.SHOW_SESSION_MENU, SyncedTabsHistogram.LIMIT);
+ }
},
onOpenAllTap_: function() {
var menu = assert(this.$.menu.getIfExists());

Powered by Google App Engine
This is Rietveld 408576698