Skip to content

Commit

Permalink
Fix IE11 regressions (#1856)
Browse files Browse the repository at this point in the history
* Fix IE11 not resetting style properties

* Fix "new Event" not supported in IE11
  • Loading branch information
marvinhagemeister authored and JoviDeCroock committed Aug 11, 2019
1 parent 871ec4c commit 00a7289
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/diff/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function setStyle(style, key, value) {
style.setProperty(key, value);
}
else {
style[key] = typeof value==='number' && IS_NON_DIMENSIONAL.test(key)===false ? value+'px' : value || null;
style[key] = typeof value==='number' && IS_NON_DIMENSIONAL.test(key)===false ? value+'px' : value || '';
}
}

Expand Down
13 changes: 11 additions & 2 deletions test-utils/test/shared/act.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ import { useEffect, useState } from 'preact/hooks';
import { setupScratch, teardown } from '../../../test/_util/helpers';
import { act } from '../../src';

// IE11 doesn't support `new Event()`
function createEvent(name) {
if (typeof Event === 'function') return new Event(name);

const event = document.createEvent('Event');
event.initEvent(name, true, true);
return event;
}

/** @jsx h */
describe('act', () => {

Expand Down Expand Up @@ -156,13 +165,13 @@ describe('act', () => {

// Click button. This will schedule an update which is deferred, as is
// normal for Preact, since it happens outside an `act` call.
button.dispatchEvent(new Event('click'));
button.dispatchEvent(createEvent('click'));

expect(button.textContent).to.equal('0');

act(() => {
// Click button a second time. This will schedule a second update.
button.dispatchEvent(new Event('click'));
button.dispatchEvent(createEvent('click'));
});
// All state updates should be applied synchronously after the `act`
// callback has run but before `act` returns.
Expand Down

0 comments on commit 00a7289

Please sign in to comment.