Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix bug when removing a css class #361

Merged
merged 1 commit into from

2 participants

@johnthethird

When removing a css class name from a list of names, replace with a space char to ensure class="one two three" doesnt become class="onethree". I've also tweaked a test to catch this scenario.

@airhorns airhorns merged commit 31cad7e into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 17, 2012
  1. @johnthethird
This page is out of date. Refresh to see the latest.
View
2  src/batman.coffee
@@ -4991,7 +4991,7 @@ class Batman.DOM.AddClassBinding extends Batman.DOM.AbstractAttributeBinding
if !!value is !@invert
@node.className = "#{currentName} #{name}" if !includesClassName
else
- @node.className = currentName.replace(pattern, '') if includesClassName
+ @node.className = currentName.replace(pattern, ' ') if includesClassName
true
class Batman.DOM.EventBinding extends Batman.DOM.AbstractAttributeBinding
View
6 tests/batman/view/class_binding_test.coffee
@@ -51,19 +51,21 @@ asyncTest 'it should allow multiple class names to be bound and updated', ->
equal node[0].className, 'bar baz'
-asyncTest 'it should allow an already present class to be removed', 4, ->
- source = '<div data-removeclass-two="bar" class="zero two"></div>'
+asyncTest 'it should allow an already present class to be removed', 6, ->
+ source = '<div data-removeclass-two="bar" class="zero two three"></div>'
context = Batman
foo: true
bar: false
helpers.render source, context, (node) ->
ok node.hasClass('zero')
ok node.hasClass('two')
+ ok node.hasClass('three')
context.set 'bar', true
delay ->
ok node.hasClass('zero')
ok !node.hasClass('two')
+ ok node.hasClass('three')
asyncTest 'it should not remove an already present similar class name', 6, ->
source = '<div data-removeclass-foobar="bar" class="zero bar"></div>'
Something went wrong with that request. Please try again.