Skip to content

Commit

Permalink
Don't overwrite classes specified in expression
Browse files Browse the repository at this point in the history
  • Loading branch information
fgnass committed Apr 12, 2012
1 parent 3d9c846 commit 6099079
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions mkay.js
Expand Up @@ -47,6 +47,7 @@ function mk(jsonml) {
$.each(attrs, function(name, val) {
m = re.event.exec(name)
if (m) chain.on(m[1], val)
else if (name == 'class') chain.addClass(val)
else chain.attr(name, val)
})

Expand Down
2 changes: 0 additions & 2 deletions mkay.min.js

This file was deleted.

7 changes: 6 additions & 1 deletion test.html
Expand Up @@ -77,11 +77,16 @@

test('attr', function() {
var el = $.mk('input.text[type=checkbox][name=foo]')[0];
equal(el.className, 'text', 'clas must be text');
equal(el.className, 'text', 'class must be text');
equal(el.type, 'checkbox', 'type must be set to checkbox');
equal(el.name, 'foo', 'name must be set to foo');
})

test('double class', function() {
var el = $.mk('.foo', {'class': 'bar'})[0];
equal(el.className, 'foo bar', 'class must match');
})

test("JsonML", function() {
var el = $.mk(
['a', {href: '#'},
Expand Down

0 comments on commit 6099079

Please sign in to comment.