|
225 | 225 | for (var i=0; i<notes.length; i++) { |
226 | 226 | var note = notes[i]; |
227 | 227 | var node = nodes[i]; |
228 | | - // nested template contents have been stored prototypically to avoid |
229 | | - // unnecessary duplication, here we put references to the |
230 | | - // indirected contents onto the nested template instances |
231 | | - if (note.templateContent) { |
232 | | - // note: we can rely on _nodes being set here and having the same |
233 | | - // index as _notes |
234 | | - this._nodes[i]._content = note.templateContent; |
235 | | - } |
236 | | - // Compound bindings utilize private storage on the node to store |
237 | | - // the current state of each value that will be concatenated to generate |
238 | | - // the final property/attribute/text value |
239 | | - // Here we initialize the private storage array on the node with any |
240 | | - // literal parts that won't change (could get fancy and use WeakMap), |
241 | | - // and configure property bindings to children with the literal parts |
242 | | - // (textContent and annotations were already initialized in the template) |
243 | | - var bindings = note.bindings; |
244 | | - for (var j=0; j<bindings.length; j++) { |
245 | | - var binding = bindings[j]; |
246 | | - if (binding.isCompound) { |
247 | | - // Create compound storage map |
248 | | - var storage = node.__compoundStorage__ || |
249 | | - (node.__compoundStorage__ = {}); |
250 | | - var parts = binding.parts; |
251 | | - // Copy literals from parts into storage for this binding |
252 | | - var literals = new Array(parts.length); |
253 | | - for (var k=0; k<parts.length; k++) { |
254 | | - literals[k] = parts[k].literal; |
255 | | - } |
256 | | - var name = binding.name; |
257 | | - storage[name] = literals; |
258 | | - // Configure properties with their literal parts |
259 | | - if (binding.kind == 'property') { |
260 | | - var literal = literals.join(''); |
261 | | - if (node._configValue) { |
262 | | - node._configValue(name, literal); |
263 | | - } else { |
264 | | - node[name] = literal; |
265 | | - } |
| 228 | + this._configureTemplateContent(note, node); |
| 229 | + this._configureCompoundBindings(note, node); |
| 230 | + } |
| 231 | + }, |
| 232 | + |
| 233 | + // nested template contents have been stored prototypically to avoid |
| 234 | + // unnecessary duplication, here we put references to the |
| 235 | + // indirected contents onto the nested template instances |
| 236 | + _configureTemplateContent: function(note, node) { |
| 237 | + if (note.templateContent) { |
| 238 | + // note: we can rely on _nodes being set here and having the same |
| 239 | + // index as _notes |
| 240 | + node._content = note.templateContent; |
| 241 | + } |
| 242 | + }, |
| 243 | + |
| 244 | + // Compound bindings utilize private storage on the node to store |
| 245 | + // the current state of each value that will be concatenated to generate |
| 246 | + // the final property/attribute/text value |
| 247 | + // Here we initialize the private storage array on the node with any |
| 248 | + // literal parts that won't change (could get fancy and use WeakMap), |
| 249 | + // and configure property bindings to children with the literal parts |
| 250 | + // (textContent and annotations were already initialized in the template) |
| 251 | + _configureCompoundBindings: function(note, node) { |
| 252 | + var bindings = note.bindings; |
| 253 | + for (var i=0; i<bindings.length; i++) { |
| 254 | + var binding = bindings[i]; |
| 255 | + if (binding.isCompound) { |
| 256 | + // Create compound storage map |
| 257 | + var storage = node.__compoundStorage__ || |
| 258 | + (node.__compoundStorage__ = {}); |
| 259 | + var parts = binding.parts; |
| 260 | + // Copy literals from parts into storage for this binding |
| 261 | + var literals = new Array(parts.length); |
| 262 | + for (var j=0; j<parts.length; j++) { |
| 263 | + literals[j] = parts[j].literal; |
| 264 | + } |
| 265 | + var name = binding.name; |
| 266 | + storage[name] = literals; |
| 267 | + // Configure properties with their literal parts |
| 268 | + if (binding.kind == 'property') { |
| 269 | + var literal = literals.join(''); |
| 270 | + if (node._configValue) { |
| 271 | + node._configValue(name, literal); |
| 272 | + } else { |
| 273 | + node[name] = literal; |
266 | 274 | } |
267 | 275 | } |
268 | 276 | } |
|
0 commit comments