Fix selector classes overriding property classes

pull/2/head
paldepind 10 years ago
parent 0010ed3967
commit 157a159283

@ -70,7 +70,9 @@ function arrInvoker(arr) {
}
function updateProps(elm, oldVnode, vnode) {
var key, val, name, cur, old, oldProps = oldVnode.props, props = vnode.props;
var key, name, cur, old, oldProps = oldVnode.props, props = vnode.props,
val = props.className;
if (isUndef(oldProps) || val !== oldProps.className) elm.className = val;
for (key in props) {
val = props[key];
if (key === 'style' || key === 'class') {
@ -99,7 +101,7 @@ function updateProps(elm, oldVnode, vnode) {
old[1] = val[1]; // captured in closure created with `arrInvoker`
}
}
} else if (key !== 'key') {
} else if (key !== 'key' && key !== 'className') {
elm[key] = val;
}
}

@ -103,6 +103,12 @@ describe('snabbdom', function() {
assert(elm.classList.contains('class'));
assert(!elm.classList.contains('not'));
});
it('handles classes from both selector and property', function() {
var elm = createElm(h('i.has', {class: {classes: true}}));
console.log(elm.classList);
assert(elm.classList.contains('has'));
assert(elm.classList.contains('classes'));
});
it('can create elements with text content', function() {
var elm = createElm(h('a', ['I am a string']));
assert.equal(elm.innerHTML, 'I am a string');

Loading…
Cancel
Save