Prefer single-quoted strings when we don't need string interpolation or special symbols.
Showing
1 changed file
with
14 additions
and
14 deletions
... | @@ -7,7 +7,7 @@ | ... | @@ -7,7 +7,7 @@ |
7 | Rivets = {} | 7 | Rivets = {} |
8 | 8 | ||
9 | # Polyfill For String::trim. | 9 | # Polyfill For String::trim. |
10 | unless String::trim then String::trim = -> @replace /^\s+|\s+$/g, "" | 10 | unless String::trim then String::trim = -> @replace /^\s+|\s+$/g, '' |
11 | 11 | ||
12 | # A single binding between a model attribute and a DOM element. | 12 | # A single binding between a model attribute and a DOM element. |
13 | class Rivets.Binding | 13 | class Rivets.Binding |
... | @@ -16,9 +16,9 @@ class Rivets.Binding | ... | @@ -16,9 +16,9 @@ class Rivets.Binding |
16 | # to listen for changes. | 16 | # to listen for changes. |
17 | constructor: (@el, @type, @model, @keypath, @options = {}) -> | 17 | constructor: (@el, @type, @model, @keypath, @options = {}) -> |
18 | @routine = switch @options.special | 18 | @routine = switch @options.special |
19 | when "event" then eventBinding @type | 19 | when 'event' then eventBinding @type |
20 | when "class" then classBinding @type | 20 | when 'class' then classBinding @type |
21 | when "iteration" then iterationBinding @type | 21 | when 'iteration' then iterationBinding @type |
22 | else Rivets.routines[@type] || attributeBinding @type | 22 | else Rivets.routines[@type] || attributeBinding @type |
23 | 23 | ||
24 | @formatters = @options.formatters || [] | 24 | @formatters = @options.formatters || [] |
... | @@ -45,15 +45,15 @@ class Rivets.Binding | ... | @@ -45,15 +45,15 @@ class Rivets.Binding |
45 | # Sets the value for the binding. This Basically just runs the binding routine | 45 | # Sets the value for the binding. This Basically just runs the binding routine |
46 | # with the suplied value formatted. | 46 | # with the suplied value formatted. |
47 | set: (value) => | 47 | set: (value) => |
48 | value = if value instanceof Function and @options.special isnt "event" | 48 | value = if value instanceof Function and @options.special isnt 'event' |
49 | @formattedValue value.call @model | 49 | @formattedValue value.call @model |
50 | else | 50 | else |
51 | @formattedValue value | 51 | @formattedValue value |
52 | 52 | ||
53 | if @options.special is "event" | 53 | if @options.special is 'event' |
54 | @routine @el, value, @currentListener | 54 | @routine @el, value, @currentListener |
55 | @currentListener = value | 55 | @currentListener = value |
56 | else if @options.special is "iteration" | 56 | else if @options.special is 'iteration' |
57 | @routine @el, value, @ | 57 | @routine @el, value, @ |
58 | else | 58 | else |
59 | @routine @el, value | 59 | @routine @el, value |
... | @@ -151,7 +151,7 @@ class Rivets.View | ... | @@ -151,7 +151,7 @@ class Rivets.View |
151 | splitPath = path.split /\.|:/ | 151 | splitPath = path.split /\.|:/ |
152 | options.formatters = pipes | 152 | options.formatters = pipes |
153 | model = @models[splitPath.shift()] | 153 | model = @models[splitPath.shift()] |
154 | options.bypass = path.indexOf(":") != -1 | 154 | options.bypass = path.indexOf(':') != -1 |
155 | keypath = splitPath.join '.' | 155 | keypath = splitPath.join '.' |
156 | 156 | ||
157 | if model | 157 | if model |
... | @@ -160,15 +160,15 @@ class Rivets.View | ... | @@ -160,15 +160,15 @@ class Rivets.View |
160 | 160 | ||
161 | if eventRegExp.test type | 161 | if eventRegExp.test type |
162 | type = type.replace eventRegExp, '' | 162 | type = type.replace eventRegExp, '' |
163 | options.special = "event" | 163 | options.special = 'event' |
164 | 164 | ||
165 | if classRegExp.test type | 165 | if classRegExp.test type |
166 | type = type.replace classRegExp, '' | 166 | type = type.replace classRegExp, '' |
167 | options.special = "class" | 167 | options.special = 'class' |
168 | 168 | ||
169 | if iterationRegExp.test type | 169 | if iterationRegExp.test type |
170 | type = type.replace iterationRegExp, '' | 170 | type = type.replace iterationRegExp, '' |
171 | options.special = "iteration" | 171 | options.special = 'iteration' |
172 | 172 | ||
173 | binding = new Rivets.Binding node, type, model, keypath, options | 173 | binding = new Rivets.Binding node, type, model, keypath, options |
174 | binding.view = @ | 174 | binding.view = @ |
... | @@ -216,7 +216,7 @@ bindEvent = (el, event, fn) -> | ... | @@ -216,7 +216,7 @@ bindEvent = (el, event, fn) -> |
216 | el.addEventListener event, fn, false | 216 | el.addEventListener event, fn, false |
217 | else | 217 | else |
218 | # Assume we are in IE and use attachEvent. | 218 | # Assume we are in IE and use attachEvent. |
219 | event = "on" + event | 219 | event = 'on' + event |
220 | el.attachEvent event, fn | 220 | el.attachEvent event, fn |
221 | 221 | ||
222 | # Cross-browser event unbinding. | 222 | # Cross-browser event unbinding. |
... | @@ -230,7 +230,7 @@ unbindEvent = (el, event, fn) -> | ... | @@ -230,7 +230,7 @@ unbindEvent = (el, event, fn) -> |
230 | el.removeEventListener event, fn, false | 230 | el.removeEventListener event, fn, false |
231 | else | 231 | else |
232 | # Assume we are in IE and use attachEvent. | 232 | # Assume we are in IE and use attachEvent. |
233 | event = "on" + event | 233 | event = 'on' + event |
234 | el.detachEvent event, fn | 234 | el.detachEvent event, fn |
235 | 235 | ||
236 | # Returns the current input value for the specified element. | 236 | # Returns the current input value for the specified element. |
... | @@ -253,7 +253,7 @@ classBinding = (name) -> (el, value) -> | ... | @@ -253,7 +253,7 @@ classBinding = (name) -> (el, value) -> |
253 | el.className = if value | 253 | el.className = if value |
254 | "#{el.className} #{name}" | 254 | "#{el.className} #{name}" |
255 | else | 255 | else |
256 | elClass.replace(" #{name} ", " ").trim() | 256 | elClass.replace(" #{name} ", ' ').trim() |
257 | 257 | ||
258 | # Returns an iteration binding routine for the specified collection. | 258 | # Returns an iteration binding routine for the specified collection. |
259 | iterationBinding = (name) -> (el, collection, binding) -> | 259 | iterationBinding = (name) -> (el, collection, binding) -> | ... | ... |
-
Please register or sign in to post a comment