Skip to content

Commit be01f5e

Browse files
committed
Cleanup IE11 mentions
1 parent f344281 commit be01f5e

File tree

7 files changed

+47
-112
lines changed

7 files changed

+47
-112
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
- Extensive React compatibility via a simple [preact/compat] alias
1414
- Everything you need: JSX, <abbr title="Virtual DOM">VDOM</abbr>, [DevTools], <abbr title="Hot Module Replacement">HMR</abbr>, <abbr title="Server-Side Rendering">SSR</abbr>.
1515
- Highly optimized diff algorithm and seamless hydration from Server Side Rendering
16-
- Supports all modern browsers and IE11
16+
- Supports all modern browsers
1717
- Transparent asynchronous rendering with a pluggable scheduler
1818

1919
### 💁 More information at the [Preact Website ➞](https://preactjs.com)

compat/test/browser/events.test.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ describe('preact/compat events', () => {
3030

3131
it('should patch events', () => {
3232
let spy = sinon.spy(event => {
33-
// Calling ev.preventDefault() outside of an event handler
34-
// does nothing in IE11. So we move these asserts inside
35-
// the event handler. We ensure that it's called once
36-
// in another assertion
3733
expect(event.isDefaultPrevented()).to.be.false;
3834
event.preventDefault();
3935
expect(event.isDefaultPrevented()).to.be.true;
@@ -89,16 +85,11 @@ describe('preact/compat events', () => {
8985
expect(vnode.props).to.not.haveOwnProperty('oninputCapture');
9086
});
9187

92-
it('should normalize onChange for range, except in IE11', () => {
93-
// NOTE: we don't normalize `onchange` for range inputs in IE11.
94-
const eventType = /Trident\//.test(navigator.userAgent)
95-
? 'change'
96-
: 'input';
97-
88+
it('should normalize onChange for range', () => {
9889
render(<input type="range" onChange={() => null} />, scratch);
9990
expect(proto.addEventListener).to.have.been.calledOnce;
10091
expect(proto.addEventListener).to.have.been.calledWithExactly(
101-
eventType,
92+
'input',
10293
sinon.match.func,
10394
false
10495
);

compat/test/browser/render.test.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,7 @@ describe('compat render', () => {
264264
scratch
265265
);
266266

267-
let html = sortAttributes(scratch.innerHTML);
268-
if (/Trident/.test(navigator.userAgent)) {
269-
html = html.toLowerCase();
270-
}
271-
272-
expect(html).to.equal(
267+
expect(sortAttributes(scratch.innerHTML)).to.equal(
273268
'<link as="image" href="preact.jpg" imagesrcset="preact_400px.jpg 400w" rel="preload">'
274269
);
275270
});

compat/test/browser/textarea.test.js

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,10 @@ describe('Textarea', () => {
3333
hydrate(<App />, scratch);
3434
expect(scratch.firstElementChild.value).to.equal('foo');
3535

36-
// IE11 always displays the value as node.innerHTML
37-
if (!/Trident/.test(window.navigator.userAgent)) {
38-
expect(scratch.innerHTML).to.be.equal('<textarea></textarea>');
39-
}
36+
expect(scratch.innerHTML).to.be.equal('<textarea></textarea>');
4037
});
4138

4239
it('should alias defaultValue to children', () => {
43-
// TODO: IE11 doesn't update `node.value` when
44-
// `node.defaultValue` is set.
45-
if (/Trident/.test(navigator.userAgent)) return;
46-
4740
render(<textarea defaultValue="foo" />, scratch);
4841

4942
expect(scratch.firstElementChild.value).to.equal('foo');
@@ -67,21 +60,13 @@ describe('Textarea', () => {
6760
// missing from HTML because innerHTML doesn't serialize form field values.
6861
// See demo: https://jsfiddle.net/4had2Lu8
6962
// Related renderToString PR: preactjs/preact-render-to-string#161
70-
//
71-
// This is not true for IE11. It displays the value in
72-
// node.innerHTML regardless.
73-
if (!/Trident/.test(window.navigator.userAgent)) {
74-
expect(scratch.innerHTML).to.equal('<textarea></textarea>');
75-
}
63+
expect(scratch.innerHTML).to.equal('<textarea></textarea>');
7664
expect(scratch.firstElementChild.value).to.equal('hello');
7765

7866
act(() => {
7967
set('');
8068
});
81-
// Same as earlier: IE11 always displays the value as node.innerHTML
82-
if (!/Trident/.test(window.navigator.userAgent)) {
83-
expect(scratch.innerHTML).to.equal('<textarea></textarea>');
84-
}
69+
expect(scratch.innerHTML).to.equal('<textarea></textarea>');
8570
expect(scratch.firstElementChild.value).to.equal('');
8671
});
8772
});

test/browser/hydrate.test.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,7 @@ describe('hydrate()', () => {
225225
clearLog();
226226
hydrate(vnode, scratch);
227227

228-
// IE11 doesn't support spying on Element.prototype
229-
if (!/Trident/.test(navigator.userAgent)) {
230-
expect(attributesSpy.get).to.not.have.been.called;
231-
}
228+
expect(attributesSpy.get).to.not.have.been.called;
232229

233230
expect(serializeHtml(scratch)).to.equal(
234231
sortAttributes(
@@ -377,10 +374,7 @@ describe('hydrate()', () => {
377374
);
378375

379376
hydrate(preactElement, scratch);
380-
// IE11 doesn't support spies on built-in prototypes
381-
if (!/Trident/.test(navigator.userAgent)) {
382-
expect(attributesSpy.get).to.not.have.been.called;
383-
}
377+
expect(attributesSpy.get).to.not.have.been.called;
384378
expect(scratch).to.have.property(
385379
'innerHTML',
386380
'<div><a foo="bar"></a></div>'

test/browser/render.test.js

Lines changed: 38 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ function getAttributes(node) {
2424
return attrs;
2525
}
2626

27-
const isIE11 = /Trident\//.test(navigator.userAgent);
28-
2927
describe('render()', () => {
3028
let scratch, rerender;
3129

@@ -84,13 +82,10 @@ describe('render()', () => {
8482
expect(scratch.innerHTML).to.eql(`<img width="100%" height="100%">`);
8583
});
8684

87-
// IE11 doesn't support these.
88-
if (!/Trident/.test(window.navigator.userAgent)) {
89-
it('should render px width and height on img correctly', () => {
90-
render(<img width="100px" height="100px" />, scratch);
91-
expect(scratch.innerHTML).to.eql(`<img width="100px" height="100px">`);
92-
});
93-
}
85+
it('should render px width and height on img correctly', () => {
86+
render(<img width="100px" height="100px" />, scratch);
87+
expect(scratch.innerHTML).to.eql(`<img width="100px" height="100px">`);
88+
});
9489

9590
it('should support the <template> tag', () => {
9691
function App() {
@@ -126,10 +121,6 @@ describe('render()', () => {
126121
expect(scratch.childNodes[0].nodeName).to.equal('SPAN');
127122
});
128123

129-
it('should not throw error in IE11 with type date', () => {
130-
expect(() => render(<input type="date" />, scratch)).to.not.throw();
131-
});
132-
133124
it('should support custom tag names', () => {
134125
render(<foo />, scratch);
135126
expect(scratch.childNodes).to.have.length(1);
@@ -168,11 +159,8 @@ describe('render()', () => {
168159
const button = div.childNodes[1];
169160
const input = div.childNodes[2];
170161

171-
// IE11 doesn't support the form attribute
172-
if (!isIE11) {
173-
expect(button).to.have.property('form', form);
174-
expect(input).to.have.property('form', form);
175-
}
162+
expect(button).to.have.property('form', form);
163+
expect(input).to.have.property('form', form);
176164
});
177165

178166
it('should allow VNode reuse', () => {
@@ -401,42 +389,38 @@ describe('render()', () => {
401389
expect(scratch.firstChild.value).to.equal('0.5');
402390
});
403391

404-
// IE or IE Edge will throw when attribute values don't conform to the
405-
// spec. That's the correct behaviour, but bad for this test...
406-
if (!/(Edge|MSIE|Trident)/.test(navigator.userAgent)) {
407-
it('should not clear falsy DOM properties', () => {
408-
function test(val) {
409-
render(
410-
<div>
411-
<input value={val} />
412-
<table border={val} />
413-
</div>,
414-
scratch
415-
);
416-
}
417-
418-
test('2');
419-
test(false);
420-
expect(scratch.innerHTML).to.equal(
421-
'<div><input><table border="false"></table></div>',
422-
'for false'
392+
it('should not clear falsy DOM properties', () => {
393+
function test(val) {
394+
render(
395+
<div>
396+
<input value={val} />
397+
<table border={val} />
398+
</div>,
399+
scratch
423400
);
401+
}
424402

425-
test('3');
426-
test(null);
427-
expect(scratch.innerHTML).to.equal(
428-
'<div><input><table border=""></table></div>',
429-
'for null'
430-
);
403+
test('2');
404+
test(false);
405+
expect(scratch.innerHTML).to.equal(
406+
'<div><input><table border="false"></table></div>',
407+
'for false'
408+
);
431409

432-
test('4');
433-
test(undefined);
434-
expect(scratch.innerHTML).to.equal(
435-
'<div><input><table border=""></table></div>',
436-
'for undefined'
437-
);
438-
});
439-
}
410+
test('3');
411+
test(null);
412+
expect(scratch.innerHTML).to.equal(
413+
'<div><input><table border=""></table></div>',
414+
'for null'
415+
);
416+
417+
test('4');
418+
test(undefined);
419+
expect(scratch.innerHTML).to.equal(
420+
'<div><input><table border=""></table></div>',
421+
'for undefined'
422+
);
423+
});
440424

441425
// Test for #3969
442426
it('should clear rowspan and colspan', () => {
@@ -1316,11 +1300,7 @@ describe('render()', () => {
13161300
'<div id="wrapper"><div id="page1">Page 1</div></div>'
13171301
);
13181302

1319-
// IE11 doesn't allow modifying Element.prototype functions properly.
1320-
// Custom spies will never be called.
1321-
if (!isIE11) {
1322-
expect(attributesSpy.get).to.not.have.been.called;
1323-
}
1303+
expect(attributesSpy.get).to.not.have.been.called;
13241304

13251305
render(
13261306
<div id="wrapper">
@@ -1332,11 +1312,7 @@ describe('render()', () => {
13321312
'<div id="wrapper"><div id="page2">Page 2</div></div>'
13331313
);
13341314

1335-
// IE11 doesn't allow modifying Element.prototype functions properly.
1336-
// Custom spies will never be called.
1337-
if (!isIE11) {
1338-
expect(attributesSpy.get).to.not.have.been.called;
1339-
}
1315+
expect(attributesSpy.get).to.not.have.been.called;
13401316
});
13411317

13421318
// #2926
@@ -1370,7 +1346,7 @@ describe('render()', () => {
13701346

13711347
// #3060
13721348
it('should reset tabindex on undefined/null', () => {
1373-
const defaultValue = isIE11 ? 0 : -1;
1349+
const defaultValue = -1;
13741350

13751351
render(<div tabIndex={0} />, scratch);
13761352
expect(scratch.firstChild.tabIndex).to.equal(0);

test/polyfills.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
import * as kl from 'kolorist';
22

3-
// Something that's loaded before this file polyfills Symbol object.
4-
// We need to verify that it works in IE without that.
5-
if (/Trident/.test(window.navigator.userAgent)) {
6-
window.Symbol = undefined;
7-
}
8-
93
// Fix Function#name on browsers that do not support it (IE).
104
// Taken from: https://stackoverflow.com/a/17056530/755391
115
if (!function f() {}.name) {

0 commit comments

Comments
 (0)