Skip to content

Commit

Permalink
Handle the class attribute removal
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianbote committed Oct 16, 2019
1 parent 9434a06 commit 0c3c03a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/diff/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ function diffElementNodes(dom, newVNode, oldVNode, context, isSvg, excessDomChil
if (oldProps === EMPTY_OBJ) {
oldProps = {};
for (let i=0; i<dom.attributes.length; i++) {
oldProps[dom.attributes[i].name] = dom.attributes[i].value;
oldProps[dom.attributes[i].name] = dom.attributes[i].value || undefined;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/diff/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function setProperty(dom, name, value, oldValue, isSvg) {
dom[name] = '';

// And remove the attribute entirely
dom.removeAttribute(name);
dom.removeAttribute(name == 'className' ? 'class' : name);
}
}
else {
Expand Down
4 changes: 2 additions & 2 deletions test/browser/render.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ describe('render()', () => {
);

render(<App />, scratch);
expect(scratch.innerHTML).to.equal('<div class=""><span>Bye</span></div>');
expect(scratch.innerHTML).to.equal('<div><span>Bye</span></div>');
});

it('should remove class attributes', () => {
Expand All @@ -495,7 +495,7 @@ describe('render()', () => {
expect(scratch.innerHTML).to.equal('<div class="hi"><span>Bye</span></div>');

render(<App />, scratch);
expect(scratch.innerHTML).to.equal('<div class=""><span>Bye</span></div>');
expect(scratch.innerHTML).to.equal('<div><span>Bye</span></div>');
});

it('should remove old styles', () => {
Expand Down

0 comments on commit 0c3c03a

Please sign in to comment.