Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 }); |
| OLD | NEW |