Skip to content

Commit

Permalink
Updated string test to catch both types of strings...
Browse files Browse the repository at this point in the history
  • Loading branch information
DamonOehlman committed Oct 17, 2011
1 parent 8b3d5bc commit ba519c0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion classtweak.js
Expand Up @@ -66,7 +66,7 @@ function classtweak(elements, initAction) {
} // tweak

// check the elements
if (typeof elements == 'string') {
if (typeof elements == 'string' || elements instanceof String) {
elements = document.querySelectorAll(elements);
}
else if (! Array.isArray(elements)) {
Expand Down
8 changes: 8 additions & 0 deletions test/specs/queryselector.js
Expand Up @@ -42,4 +42,12 @@ describe('query selector tweaks', function() {
expect(elements[1].className).toEqual('');
expect(elements[2].className).toEqual('');
});

it('can handle string objects', function() {
classtweak('section[data-route]', '+bounce');
classtweak(new String('section'), '!bounce');
expect(elements[0].className).toEqual('bounce');
expect(elements[1].className).toEqual('');
expect(elements[2].className).toEqual('');
});
});

0 comments on commit ba519c0

Please sign in to comment.