Skip to content

Commit

Permalink
nodeInfo -> nodeInfoList
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed Mar 17, 2017
1 parent 627352d commit eed6750
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
7 changes: 3 additions & 4 deletions lib/mixins/property-effects.html
Original file line number Diff line number Diff line change
Expand Up @@ -712,8 +712,7 @@
* @param {Object} inst Instance that bas been previously bound
* @private
*/
function setupBindings(inst) {
let nodeInfo = inst.__templateNodeInfo;
function setupBindings(inst, nodeInfo) {
if (nodeInfo.length) {
for (let i=0; i < nodeInfo.length; i++) {
let info = nodeInfo[i];
Expand Down Expand Up @@ -1673,7 +1672,7 @@
*/
_stampTemplate(template) {
let dom = super._stampTemplate(template);
setupBindings(this);
setupBindings(this, template._templateInfo.nodeInfoList);
return dom;
}

Expand Down Expand Up @@ -2155,7 +2154,7 @@
this.__propagateEffects = {};
this.__notifyListeners = [];
let templateInfo = this.constructor._parseTemplate(template);
let nodeInfo = templateInfo.nodeInfo;
let nodeInfo = templateInfo.nodeInfoList;
for (let i=0, info; (i<nodeInfo.length) && (info=nodeInfo[i]); i++) {
// where to find the node in the concretized list
let b$ = info.bindings;
Expand Down
45 changes: 23 additions & 22 deletions lib/mixins/template-stamp.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,6 @@
* - Map of node id's to stamped node instances (`this.$.id`)
* - Nested template content caching/removal and re-installation (performance
* optimization)
* - Relative URL's relative to original template location
* - Template binding annotation parsing (note that this library only parses
* template bindings and provides annotation metadata; see
* `Polymer.PropertyEffects` for a full implementation of data-binding)
*
* @polymerMixin
* @memberof Polymer
Expand All @@ -122,7 +118,6 @@
super();
this.$ = null;
this.__templateNodes = null;
this.__templateNodeInfo = null;
}

/**
Expand All @@ -137,38 +132,44 @@
*
* `nodeInfo` metadata captured by this library include the following:
*
* [
* nodeInfo: [
* {
* id: '<id>', // `id`
* // `id` attribute for any nodes with id's for generating `$` map
* id: '<id>',
* // `on-event="handler"` metadata
* events: [
* {
* name: '<name>'
* value: '<expression>'
* }, ...
* ],
* bindings: [
* {
* kind: ['text'|'attribute'|'property'],
* mode: ['auto'|''],
* name: '<name>'
* value: '<expression>'
* value: '<handler name>'
* }, ...
* ],
* // DocumentFragment containing template content for
* // any nested templates found; the template content is removed
* // and cached in the template metadata, as an optimization to
* // avoid the cost of deeply cloning templates
* content: <DocumentFragment>,
* // Metadata to allow efficient retrieval of instanced node
* // corresponding to this metadata
* parent: <reference to parent nodeInfo>,
* index: <integer index in parent's `childNodes` collection>
* },
* ...
* ]
*
* @param {HTMLTemplateElement} template
* @param {Object=} outerTemplateInfo
* @return {Object} Template metadata
* Note that this method may be destructive to the template, in that
* e.g. event annotations may be removed after being noted in the
* template metadata.
*
* @param {HTMLTemplateElement} template Template to parse
* @param {Object=} outerTemplateInfo Template info from the outer
* template, for parsing nested templates
* @return {Object} Parsed template metadata
*/
static _parseTemplate(template, outerTemplateInfo) {
// since a template may be re-used, memo-ize notes.
if (!template._templateInfo) {
let templateInfo = template._templateInfo || (template._templateInfo = {});
templateInfo.nodeInfo = [];
templateInfo.nodeInfoList = [];
templateInfo.stripWhiteSpace =
(outerTemplateInfo && outerTemplateInfo.stripWhiteSpace) ||
template.hasAttribute('strip-whitespace');
Expand Down Expand Up @@ -222,7 +223,7 @@
}
let childInfo = { index, parent: nodeInfo };
if (this._parseTemplateNode(node, templateInfo, childInfo)) {
templateInfo.nodeInfo.push(childInfo);
templateInfo.nodeInfoList.push(childInfo);
}
index++;
}
Expand Down Expand Up @@ -311,7 +312,7 @@
HTMLTemplateElement.decorate(template);
}
let templateInfo = this.constructor._parseTemplate(template);
let nodeInfo = this.__templateNodeInfo = templateInfo.nodeInfo;
let nodeInfo = templateInfo.nodeInfoList;
let content = templateInfo.content || template.content;
let dom = document.importNode(content, true);
// NOTE: ShadyDom optimization indicating there is an insertion point
Expand Down

0 comments on commit eed6750

Please sign in to comment.