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

Side by Side Diff: ui/webui/resources/cr_elements/cr_lazy_render/cr_lazy_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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 * cr-lazy-render is a simple variant of dom-if designed for lazy rendering 7 * cr-lazy-render is a simple variant of dom-if designed for lazy rendering
8 * of elements that are accessed imperatively. 8 * of elements that are accessed imperatively.
9 * Usage: 9 * Usage:
10 * <template is="cr-lazy-render" id="menu"> 10 * <template is="cr-lazy-render" id="menu">
11 * <heavy-menu></heavy-menu> 11 * <heavy-menu></heavy-menu>
12 * </template> 12 * </template>
13 * 13 *
14 * this.$.menu.get().show(); 14 * this.$.menu.get().show();
15 */ 15 */
16 16
17 Polymer({ 17 Polymer({
18 is: 'cr-lazy-render', 18 is: 'cr-lazy-render',
19 extends: 'template', 19 extends: 'template',
20 20
21 behaviors: [Polymer.Templatizer], 21 behaviors: [Polymer.Templatizer],
22 22
23 /** @private {TemplatizerNode} */ 23 /** @private {TemplatizerNode} */
24 child_: null, 24 child_: null,
25 25
26 /** @override */
27 detached: function() {
28 this.child_ = null;
29 },
30
26 /** 31 /**
27 * Stamp the template into the DOM tree synchronously 32 * Stamp the template into the DOM tree synchronously
28 * @return {Element} Child element which has been stamped into the DOM tree. 33 * @return {Element} Child element which has been stamped into the DOM tree.
29 */ 34 */
30 get: function() { 35 get: function() {
31 if (!this.child_) 36 if (!this.child_)
32 this.render_(); 37 this.render_();
33 return this.child_; 38 return this.child_;
34 }, 39 },
35 40
(...skipping 28 matching lines...) Expand all
64 69
65 /** 70 /**
66 * @param {string} path 71 * @param {string} path
67 * @param {Object} value 72 * @param {Object} value
68 */ 73 */
69 _forwardParentPath: function(path, value) { 74 _forwardParentPath: function(path, value) {
70 if (this.child_) 75 if (this.child_)
71 this.child_._templateInstance.notifyPath(path, value, true); 76 this.child_._templateInstance.notifyPath(path, value, true);
72 } 77 }
73 }); 78 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698