forked from preactjs/preact
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master'
* upstream/master: (341 commits) Revert "Simplify originalDom check (-4 B) " Simplify originalDom check (-4 B) Add back mistakenly removed JSDoc comment Remove unnecessary code from `diffChildren` (-16 B) Golf createContext (-6 B) Fix useContext test spacing Remove `dom` parameter from `diff()` (-11 B) Move all component diff'ing logic into component diff condition (-6 B) fix issue by marking dirty before .render since this can potentially add another entry on the render queue add relevant test (chore) - remove focusElement (preactjs#1548) Update type definition (preactjs#1581) Compress code, assume EMPTY_OBJ._children == null Refactor out variables from diffChildren Compress diffChildren further Compress diffChildren further Condense code in diffChildren Fix infinite loop because of props mutation (preactjs#1577) (fix) - Error boundary not applying in array cases (preactjs#1572) Add styled-components example (preactjs#1574) ... # Conflicts: # .eslintignore # compat/mangle.json # compat/src/index.js # compat/src/internal.d.ts # debug/mangle.json # hooks/src/index.d.ts # hooks/src/index.js # hooks/src/internal.d.ts # mangle.json # package.json # src/component.js # src/constants.js # src/create-context.js # src/create-element.js # src/diff/children.js # src/diff/index.js # src/diff/props.js # src/index.d.ts # src/internal.d.ts # src/jsx.d.ts # src/render.js # src/util.js
- Loading branch information
Showing
93 changed files
with
8,271 additions
and
6,335 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ package-lock.json | |
.idea | ||
test/ts/**/*.js | ||
coverage | ||
*.sw[op] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
sudo: false | ||
|
||
notifications: | ||
email: false | ||
|
||
language: node_js | ||
|
||
node_js: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('preact/test-utils'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { createElement, render } from 'preact'; | ||
import { setupScratch, teardown } from '../../../test/_util/helpers'; | ||
|
||
import React from 'preact/compat'; // eslint-disable-line | ||
|
||
describe('imported compat in preact', () => { | ||
|
||
let scratch; | ||
|
||
beforeEach(() => { | ||
scratch = setupScratch(); | ||
}); | ||
|
||
afterEach(() => { | ||
teardown(scratch); | ||
}); | ||
|
||
it('should patch events', () => { | ||
let spy = sinon.spy(); | ||
render(<div onClick={spy} />, scratch); | ||
scratch.firstChild.click(); | ||
|
||
expect(spy).to.be.calledOnce; | ||
expect(spy.args[0][0]).to.haveOwnProperty('persist'); | ||
expect(typeof spy.args[0][0].persist).to.equal('function'); | ||
expect(spy.args[0][0]).to.haveOwnProperty('nativeEvent'); | ||
}); | ||
|
||
it('should normalize ondoubleclick event', () => { | ||
let vnode = <div onDoubleClick={() => null} />; | ||
expect(vnode.props).to.haveOwnProperty('ondblclick'); | ||
}); | ||
|
||
it('should normalize onChange for textarea', () => { | ||
let vnode = <textarea onChange={() => null} />; | ||
expect(vnode.props).to.haveOwnProperty('oninput'); | ||
expect(vnode.props).to.not.haveOwnProperty('onchange'); | ||
|
||
vnode = <textarea oninput={() => null} onChange={() => null} />; | ||
expect(vnode.props).to.haveOwnProperty('oninput'); | ||
expect(vnode.props).to.not.haveOwnProperty('onchange'); | ||
}); | ||
|
||
it('should normalize class+className even on components', () => { | ||
function Foo(props) { | ||
return <div class={props.class} className={props.className}>foo</div>; | ||
} | ||
render(<Foo class="foo" />, scratch); | ||
expect(scratch.firstChild.className).to.equal('foo'); | ||
render(null, scratch); | ||
|
||
render(<Foo className="foo" />, scratch); | ||
expect(scratch.firstChild.className).to.equal('foo'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { setupScratch, teardown } from '../../../test/_util/helpers'; | ||
import { render, createElement as h } from '../../src'; | ||
|
||
/** @jsx h */ | ||
|
||
describe('Select', () => { | ||
let scratch; | ||
|
||
beforeEach(() => { | ||
scratch = setupScratch(); | ||
}); | ||
|
||
afterEach(() => { | ||
teardown(scratch); | ||
}); | ||
|
||
|
||
it('should work with multiple selected (array of values)', () => { | ||
function App() { | ||
return ( | ||
<select multiple value={['B', 'C']}> | ||
<option value="A">A</option> | ||
<option value="B">B</option> | ||
<option value="C">C</option> | ||
</select> | ||
); | ||
} | ||
|
||
render(<App />, scratch); | ||
Array.prototype.slice.call(scratch.firstChild.childNodes).forEach(node => { | ||
if (node.value === 'B' || node.value === 'C') { | ||
expect(node.selected).to.equal(true); | ||
} | ||
}); | ||
expect(scratch.firstChild.value).to.equal('B'); | ||
}); | ||
}); |
Oops, something went wrong.