6cb9af1e by Michael Richards

Add the textNode internal binder for fast lookups when building out textNode bindings. [#181]

1 parent 266a3308
...@@ -24,7 +24,7 @@ class Rivets.Binding ...@@ -24,7 +24,7 @@ class Rivets.Binding
24 # containing view, the DOM node, the type of binding, the model object and the 24 # containing view, the DOM node, the type of binding, the model object and the
25 # keypath at which to listen for changes. 25 # keypath at which to listen for changes.
26 constructor: (@view, @el, @type, @key, @keypath, @options = {}) -> 26 constructor: (@view, @el, @type, @key, @keypath, @options = {}) ->
27 unless @binder = @view.binders[type] 27 unless @binder = Rivets.internalBinders[@type] or @view.binders[type]
28 for identifier, value of @view.binders 28 for identifier, value of @view.binders
29 if identifier isnt '*' and identifier.indexOf('*') isnt -1 29 if identifier isnt '*' and identifier.indexOf('*') isnt -1
30 regexp = new RegExp "^#{identifier.replace('*', '.+')}$" 30 regexp = new RegExp "^#{identifier.replace('*', '.+')}$"
...@@ -537,6 +537,15 @@ Rivets.binders = ...@@ -537,6 +537,15 @@ Rivets.binders =
537 else 537 else
538 el.removeAttribute @type 538 el.removeAttribute @type
539 539
540 # Rivets.internalBinders
541 # ----------------------
542
543 # Contextually sensitive binders that are used outside of the standard attribute
544 # bindings. Put here for fast lookups and to prevent them from being overridden.
545 Rivets.internalBinders =
546 textNode: (node, value) ->
547 node.data = value ? ''
548
540 # Rivets.config 549 # Rivets.config
541 # ------------- 550 # -------------
542 551
......