Update the buildBinding function to take the type of binding as the first argument.
Showing
1 changed file
with
5 additions
and
5 deletions
... | @@ -263,7 +263,7 @@ class Rivets.View | ... | @@ -263,7 +263,7 @@ class Rivets.View |
263 | componentRegExp = @componentRegExp() | 263 | componentRegExp = @componentRegExp() |
264 | 264 | ||
265 | 265 | ||
266 | buildBinding = (node, type, declaration) => | 266 | buildBinding = (binding, node, type, declaration) => |
267 | options = {} | 267 | options = {} |
268 | 268 | ||
269 | pipes = (pipe.trim() for pipe in declaration.split '|') | 269 | pipes = (pipe.trim() for pipe in declaration.split '|') |
... | @@ -284,7 +284,7 @@ class Rivets.View | ... | @@ -284,7 +284,7 @@ class Rivets.View |
284 | if dependencies = context.shift() | 284 | if dependencies = context.shift() |
285 | options.dependencies = dependencies.split /\s+/ | 285 | options.dependencies = dependencies.split /\s+/ |
286 | 286 | ||
287 | @bindings.push new Rivets.Binding @, node, type, key, keypath, options | 287 | @bindings.push new Rivets[binding] @, node, type, key, keypath, options |
288 | 288 | ||
289 | parse = (node) => | 289 | parse = (node) => |
290 | unless node in skipNodes | 290 | unless node in skipNodes |
... | @@ -299,11 +299,11 @@ class Rivets.View | ... | @@ -299,11 +299,11 @@ class Rivets.View |
299 | 299 | ||
300 | switch startToken.type | 300 | switch startToken.type |
301 | when 0 then node.data = startToken.value | 301 | when 0 then node.data = startToken.value |
302 | when 1 then buildBinding node, 'textNode', startToken.value | 302 | when 1 then buildBinding 'TextBinding', node, null, startToken.value |
303 | 303 | ||
304 | for token in restTokens | 304 | for token in restTokens |
305 | node.parentNode.appendChild (text = document.createTextNode token.value) | 305 | node.parentNode.appendChild (text = document.createTextNode token.value) |
306 | buildBinding text, 'textNode', token.value if token.type is 1 | 306 | buildBinding 'TextBinding', text, null, token.value if token.type is 1 |
307 | else if componentRegExp.test node.tagName | 307 | else if componentRegExp.test node.tagName |
308 | type = node.tagName.replace(componentRegExp, '').toLowerCase() | 308 | type = node.tagName.replace(componentRegExp, '').toLowerCase() |
309 | @bindings.push new Rivets.ComponentBinding @, node, type | 309 | @bindings.push new Rivets.ComponentBinding @, node, type |
... | @@ -328,7 +328,7 @@ class Rivets.View | ... | @@ -328,7 +328,7 @@ class Rivets.View |
328 | for attribute in attributes or node.attributes | 328 | for attribute in attributes or node.attributes |
329 | if bindingRegExp.test attribute.name | 329 | if bindingRegExp.test attribute.name |
330 | type = attribute.name.replace bindingRegExp, '' | 330 | type = attribute.name.replace bindingRegExp, '' |
331 | buildBinding node, type, attribute.value | 331 | buildBinding 'Binding', node, type, attribute.value |
332 | 332 | ||
333 | parse childNode for childNode in node.childNodes | 333 | parse childNode for childNode in node.childNodes |
334 | 334 | ... | ... |
-
Please register or sign in to post a comment