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); |
} |
}); |