Skip all nodes in an iteration context unless building the views for the iterated items.
Showing
1 changed file
with
14 additions
and
0 deletions
... | @@ -114,13 +114,27 @@ class Rivets.View | ... | @@ -114,13 +114,27 @@ class Rivets.View |
114 | # Builds the Rivets.Binding instances for the view. | 114 | # Builds the Rivets.Binding instances for the view. |
115 | build: => | 115 | build: => |
116 | @bindings = [] | 116 | @bindings = [] |
117 | skipNodes = [] | ||
118 | iterator = null | ||
117 | bindingRegExp = @bindingRegExp() | 119 | bindingRegExp = @bindingRegExp() |
118 | eventRegExp = /^on-/ | 120 | eventRegExp = /^on-/ |
119 | iterationRegExp = /^each-/ | 121 | iterationRegExp = /^each-/ |
120 | 122 | ||
121 | parseNode = (node) => | 123 | parseNode = (node) => |
124 | unless node in skipNodes | ||
122 | for attribute in node.attributes | 125 | for attribute in node.attributes |
123 | if bindingRegExp.test attribute.name | 126 | if bindingRegExp.test attribute.name |
127 | type = attribute.name.replace bindingRegExp, '' | ||
128 | |||
129 | if iterationRegExp.test type | ||
130 | unless @models[type.replace iterationRegExp, ''] | ||
131 | skipNodes.push n for n in node.getElementsByTagName '*' | ||
132 | iterator = [attribute] | ||
133 | |||
134 | for attribute in iterator or node.attributes | ||
135 | iterator = null | ||
136 | |||
137 | if bindingRegExp.test attribute.name | ||
124 | options = {} | 138 | options = {} |
125 | 139 | ||
126 | type = attribute.name.replace bindingRegExp, '' | 140 | type = attribute.name.replace bindingRegExp, '' | ... | ... |
-
Please register or sign in to post a comment