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

Side by Side Diff: chrome/browser/resources/settings/controls/settings_idle_render.js

Issue 2669153003: [MD settings] handle being detached on cr-lazy-render and settings-idle-render
Patch Set: handling get() when detached Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | ui/webui/resources/cr_elements/cr_lazy_render/cr_lazy_render.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * settings-idle-render is a simple variant of dom-if designed for lazy 7 * settings-idle-render is a simple variant of dom-if designed for lazy
8 * rendering of elements that are accessed imperatively. 8 * rendering of elements that are accessed imperatively.
9 * If a use for idle time expansion is found outside of settings, this code 9 * If a use for idle time expansion is found outside of settings, this code
10 * should be replaced by cr-lazy-render after that feature is merged into 10 * should be replaced by cr-lazy-render after that feature is merged into
(...skipping 12 matching lines...) Expand all
23 /** @private {number} */ 23 /** @private {number} */
24 idleCallback_: 0, 24 idleCallback_: 0,
25 25
26 /** @override */ 26 /** @override */
27 attached: function() { 27 attached: function() {
28 this.idleCallback_ = requestIdleCallback(this.render_.bind(this)); 28 this.idleCallback_ = requestIdleCallback(this.render_.bind(this));
29 }, 29 },
30 30
31 /** @override */ 31 /** @override */
32 detached: function() { 32 detached: function() {
33 this.child_ = null;
Dan Beam 2017/02/11 23:01:35 but wait, does this mean it could get double-rende
tsergeant 2017/02/15 06:31:39 Yeah, if you detach the settings-idle-render, its
33 // No-op if callback already fired. 34 // No-op if callback already fired.
34 cancelIdleCallback(this.idleCallback_); 35 cancelIdleCallback(this.idleCallback_);
35 }, 36 },
36 37
37 /** 38 /**
38 * Stamp the template into the DOM tree synchronously 39 * Stamp the template into the DOM tree synchronously
39 * @return {Element} Child element which has been stamped into the DOM tree. 40 * @return {Element} Child element which has been stamped into the DOM tree.
40 */ 41 */
41 get: function() { 42 get: function() {
42 if (!this.child_) 43 if (!this.child_)
(...skipping 24 matching lines...) Expand all
67 68
68 /** 69 /**
69 * @param {string} path 70 * @param {string} path
70 * @param {Object} value 71 * @param {Object} value
71 */ 72 */
72 _forwardParentPath: function(path, value) { 73 _forwardParentPath: function(path, value) {
73 if (this.child_) 74 if (this.child_)
74 this.child_._templateInstance.notifyPath(path, value, true); 75 this.child_._templateInstance.notifyPath(path, value, true);
75 } 76 }
76 }); 77 });
OLDNEW
« no previous file with comments | « no previous file | ui/webui/resources/cr_elements/cr_lazy_render/cr_lazy_render.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698