Skip to content

Commit

Permalink
fix(ClassObserver): split classes by any ASCII whitespace. fixes #257
Browse files Browse the repository at this point in the history
  • Loading branch information
gheoan committed Dec 13, 2015
1 parent 44b5a66 commit 776eef4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/class-observer.js
Expand Up @@ -17,7 +17,7 @@ export class ClassObserver {

// Add the classes, tracking the version at which they were added.
if (newValue !== null && newValue !== undefined && newValue.length) {
names = newValue.split(' ');
names = newValue.split(/\s+/);
for(let i = 0, length = names.length; i < length; i++) {
name = names[i];
if (name === '') {
Expand Down
4 changes: 2 additions & 2 deletions test/class-observer.spec.js
Expand Up @@ -28,10 +28,10 @@ describe('ClassObserver', () => {
it('adds and removes own classes', () => {
var contains = element.classList.contains.bind(element.classList);
expect(contains('foo') && contains('bar')).toBe(true);
observerA.setValue(' xxx yyy ');
observerA.setValue(' xxx \t\r\n\v\f yyy ');
expect(contains('foo') && contains('bar')).toBe(true);
expect(contains('xxx') && contains('yyy')).toBe(true);
expect(observerA.getValue()).toBe(' xxx yyy ');
expect(observerA.getValue()).toBe(' xxx \t\r\n\v\f yyy ');
observerA.setValue('');
expect(contains('foo') && contains('bar')).toBe(true);
expect(contains('xxx') || contains('yyy')).toBe(false);
Expand Down

0 comments on commit 776eef4

Please sign in to comment.