-
-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix preact/debug throwing on string children
- Loading branch information
1 parent
32acce9
commit 8b944b2
Showing
3 changed files
with
53 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'preact-render-to-string': patch | ||
--- | ||
|
||
Fix `preact/debug` incorrectly throwing errors on text children |
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,26 @@ | ||
import 'preact/debug'; | ||
import { render } from '../src'; | ||
import { h } from 'preact'; | ||
import { expect } from 'chai'; | ||
|
||
describe('debug', () => { | ||
it('should not throw "Objects are not valid as a child" error', () => { | ||
expect(() => render(<p>{'foo'}</p>)).not.to.throw(); | ||
expect(() => render(<p>{2}</p>)).not.to.throw(); | ||
expect(() => render(<p>{true}</p>)).not.to.throw(); | ||
expect(() => render(<p>{false}</p>)).not.to.throw(); | ||
expect(() => render(<p>{null}</p>)).not.to.throw(); | ||
expect(() => render(<p>{undefined}</p>)).not.to.throw(); | ||
}); | ||
|
||
it('should not throw "Objects are not valid as a child" error #2', () => { | ||
function Str() { | ||
return ['foo']; | ||
} | ||
expect(() => render(<Str />)).not.to.throw(); | ||
}); | ||
|
||
it('should not throw "Objects are not valid as a child" error #3', () => { | ||
expect(() => render(<p>{'foo'}bar</p>)).not.to.throw(); | ||
}); | ||
}); |