diff --git a/lib/legacy/legacy-element-mixin.html b/lib/legacy/legacy-element-mixin.html
index 6272b1cecf..f3770414aa 100644
--- a/lib/legacy/legacy-element-mixin.html
+++ b/lib/legacy/legacy-element-mixin.html
@@ -286,8 +286,9 @@
* template content.
*/
instanceTemplate(template) {
+ let content = this.constructor._contentForTemplate(template);
let dom = /** @type {DocumentFragment} */
- (document.importNode(template._content || template.content, true));
+ (document.importNode(content, true));
return dom;
}
diff --git a/lib/mixins/property-effects.html b/lib/mixins/property-effects.html
index 259bd86ba3..26a30824fa 100644
--- a/lib/mixins/property-effects.html
+++ b/lib/mixins/property-effects.html
@@ -683,16 +683,9 @@
* @private
*/
function addAnnotatedListener(model, index, property, path, event, negate) {
- let eventName = event ||
- (CaseMap.camelToDashCase(property) + '-changed');
+ event = event || (CaseMap.camelToDashCase(property) + '-changed');
model.__notifyListeners = model.__notifyListeners || [];
- model.__notifyListeners.push({
- index: index,
- property: property,
- path: path,
- event: eventName,
- negate: negate
- });
+ model.__notifyListeners.push({ index, property, path, event, negate });
}
/**
@@ -711,7 +704,7 @@
}
/**
- * On the `inst` element that was previously bound, uses `inst.__templateNotes`
+ * On the `inst` element that was previously bound, uses `inst.__templateNodeInfo`
* to setup compound binding storage structures onto the bound
* nodes (`inst.__templateNodes`).
* (`inst._, and 2-way binding event listeners are also added.)
@@ -720,14 +713,15 @@
* @private
*/
function setupBindings(inst) {
- let notes = inst.__templateNotes;
- if (notes.length) {
- for (let i=0; i < notes.length; i++) {
- let note = notes[i];
+ let nodeInfo = inst.__templateNodeInfo;
+ if (nodeInfo.length) {
+ for (let i=0; i < nodeInfo.length; i++) {
+ let info = nodeInfo[i];
let node = inst.__templateNodes[i];
node.__dataHost = inst;
- if (note.bindings) {
- setupCompoundBinding(note, node);
+ let bindings = info.bindings;
+ if (bindings) {
+ setupCompoundBinding(bindings, node);
}
}
}
@@ -833,7 +827,7 @@
// m[1]: '{{' '[['
// m[2]: '' '!'
// m[3]: 'prop' 'compute(foo,bar)'
- while ((m = bindingRegex.exec(text)) !== null) {
+ while ((m = bindingRegex.exec(text))) {
// Add literal part
if (m.index > lastIndex) {
parts.push({literal: text.slice(lastIndex, m.index)});
@@ -843,9 +837,9 @@
let mode = m[1][0];
let negate = Boolean(m[2]);
let value = m[3].trim();
- let customEvent, notifyEvent, colon;
+ let customEvent, event, colon;
if (mode == '{' && (colon = value.indexOf('::')) > 0) {
- notifyEvent = value.substring(colon + 2);
+ event = value.substring(colon + 2);
value = value.substring(0, colon);
customEvent = true;
}
@@ -856,14 +850,8 @@
hostProps[rootProperty] = true;
}
parts.push({
- compoundIndex: parts.length,
- value,
- mode,
- negate,
- event: notifyEvent,
- customEvent,
- signature,
- rootProperty
+ value, mode, negate, event, customEvent, signature, rootProperty,
+ compoundIndex: parts.length
});
lastIndex = bindingRegex.lastIndex;
}
@@ -871,9 +859,7 @@
if (lastIndex && lastIndex < text.length) {
let literal = text.substring(lastIndex);
if (literal) {
- parts.push({
- literal: literal
- });
+ parts.push({ literal });
}
}
if (parts.length) {
@@ -935,8 +921,9 @@
let arg = parseArg(rawArg);
if (!arg.literal) {
sig.static = false;
- } else if (hostProps) {
- hostProps[arg.rootProperty] = true;
+ if (hostProps) {
+ hostProps[arg.rootProperty] = true;
+ }
}
return arg;
}, this);
@@ -1064,12 +1051,11 @@
* storage array for that property, and then the array is joined to result in
* the final value set to the property/attribute.
*
- * @param {Object} note Annotation metadata
+ * @param {Object} bindings Binding metadata
* @param {Node} node Bound node to initialize
* @private
*/
- function setupCompoundBinding(note, node) {
- let bindings = note.bindings;
+ function setupCompoundBinding(bindings, node) {
for (let i=0; i="expression"
+ * Template-specific metadata are stored in the object returned, and node-
+ * specific metadata are stored in objects in its flattened `nodeInfoList`
+ * array. Only nodes in the template that were parsed as nodes of
+ * interest contain an object in `nodeInfoList`. Each `nodeInfo` object
+ * contains an `index` (`childNodes` index in parent) and optionally
+ * `parent`, which points to node info of its parent (including its index).
+ *
+ * `nodeInfo` metadata captured by this library include the following:
*
- * Generated data-structure:
* [
* {
- * id: '',
+ * id: '', // `id`
* events: [
* {
- * mode: ['auto'|''],
* name: ''
* value: ''
* }, ...
@@ -161,134 +154,116 @@
* value: ''
* }, ...
* ],
- * parent: ,
- * index:
+ * parent: ,
+ * index:
* },
* ...
* ]
*
* @param {HTMLTemplateElement} template
- * @param {boolean=} stripWhiteSpace
- * @param {Document=} ownerDocument
- * @return {Array