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

Unified Diff: ui/webui/resources/cr_elements/cr_lazy_render/cr_lazy_render.js

Issue 2344803002: MD WebUI: Simplify usage of Templatizer in cr-lazy-render (Closed)
Patch Set: 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
« no previous file with comments | « chrome/browser/resources/md_history/app.crisper.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/webui/resources/cr_elements/cr_lazy_render/cr_lazy_render.js
diff --git a/ui/webui/resources/cr_elements/cr_lazy_render/cr_lazy_render.js b/ui/webui/resources/cr_elements/cr_lazy_render/cr_lazy_render.js
index 0c4fb80e935048c9ad1682e0c448c2e9d5f6179e..99da50e48340df4781abe7f0d749b1103ca0069f 100644
--- a/ui/webui/resources/cr_elements/cr_lazy_render/cr_lazy_render.js
+++ b/ui/webui/resources/cr_elements/cr_lazy_render/cr_lazy_render.js
@@ -16,30 +16,6 @@
* });
*/
-/**
- * A template instance created by Polymer.Templatizer.
- * @constructor
- * @extends {PolymerElement}
- */
-var TemplateInstance = function() {};
-
-/** @type {Array<Element>} */
-TemplateInstance.prototype._children;
-
-/**
- * @param {string} prop
- * @param {Object} value
- * @param {boolean} quiet
- */
-TemplateInstance.prototype.__setProperty = function(prop, value, quiet) {};
-
-/**
- * @param {string} path
- * @param {Object} value
- * @param {boolean} quiet
- */
-TemplateInstance.prototype._notifyPath = function(path, value, quiet) {};
-
Polymer({
is: 'cr-lazy-render',
extends: 'template',
@@ -51,8 +27,8 @@ Polymer({
/** @private {Promise<Element>} */
_renderPromise: null,
- /** @private {TemplateInstance} */
- _instance: null,
+ /** @private {TemplatizerNode} */
+ _child: null,
Dan Beam 2016/09/15 17:19:00 use trailing underscore for Chrome JS unless it ha
tsergeant 2016/09/15 23:26:49 I was originally trying to avoid things like `inst
/**
* Stamp the template into the DOM tree asynchronously
@@ -77,25 +53,18 @@ Polymer({
* already been stamped.
*/
getIfExists: function() {
- if (this._instance) {
- var children = this._instance._children;
-
- for (var i = 0; i < children.length; i++) {
- if (children[i].nodeType == Node.ELEMENT_NODE)
- return children[i];
- }
- }
- return null;
+ return this._child;
},
+ /** @private */
Dan Beam 2016/09/15 17:19:00 is this actually private or @protected in polymer
tsergeant 2016/09/15 23:26:49 It's private, yeah. Nothing else should be using i
_render: function() {
if (!this.ctor)
this.templatize(this);
var parentNode = this.parentNode;
- if (parentNode && !this._instance) {
- this._instance = /** @type {TemplateInstance} */(this.stamp({}));
- var root = this._instance.root;
- parentNode.insertBefore(root, this);
+ if (parentNode && !this._child) {
+ var instance = this.stamp({});
+ this._child = instance.root.querySelector('*');
michaelpg 2016/09/15 08:44:41 instance.root.firstElementChild
tsergeant 2016/09/15 23:26:49 Done.
+ parentNode.insertBefore(instance.root, this);
}
},
@@ -104,8 +73,8 @@ Polymer({
* @param {Object} value
*/
_forwardParentProp: function(prop, value) {
- if (this._instance)
- this._instance.__setProperty(prop, value, true);
+ if (this._child)
+ this._child._templateInstance[prop] = value;
},
/**
@@ -113,7 +82,7 @@ Polymer({
* @param {Object} value
*/
_forwardParentPath: function(path, value) {
- if (this._instance)
- this._instance._notifyPath(path, value, true);
+ if (this._child)
+ this._child._templateInstance.notifyPath(path, value, true);
}
});
« no previous file with comments | « chrome/browser/resources/md_history/app.crisper.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698