Skip to content

Commit

Permalink
Merge branch 'main' into skip-comment-nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock authored Oct 9, 2023
2 parents ead72db + 4b1a7e9 commit e866710
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/create-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ export function Fragment(props) {
* @returns {vnode is import('./internal').VNode}
*/
export const isValidElement = vnode =>
vnode != null && vnode.constructor === undefined;
vnode != null && vnode.constructor == undefined;
2 changes: 1 addition & 1 deletion src/diff/children.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function diffChildren(
// or we are rendering a component (e.g. setState) copy the oldVNodes so it can have
// it's own DOM & etc. pointers
else if (
typeof childVNode == 'string' ||
childVNode.constructor == String ||
typeof childVNode == 'number' ||
// eslint-disable-next-line valid-typeof
typeof childVNode == 'bigint'
Expand Down
2 changes: 1 addition & 1 deletion src/diff/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export function setProperty(dom, name, value, oldValue, isSvg) {
// amount of exceptions would cost too many bytes. On top of
// that other frameworks generally stringify `false`.

if (typeof value === 'function') {
if (typeof value == 'function') {
// never serialize functions as attribute values
} else if (value != null && (value !== false || name[4] === '-')) {
dom.setAttribute(name, value);
Expand Down
2 changes: 1 addition & 1 deletion src/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function render(vnode, parentDom, replaceNode) {
// We abuse the `replaceNode` parameter in `hydrate()` to signal if we are in
// hydration mode or not by passing the `hydrate` function instead of a DOM
// element..
let isHydrating = typeof replaceNode === 'function';
let isHydrating = typeof replaceNode == 'function';

// To be able to support calling `render()` multiple times on the same
// DOM node, we need to obtain a reference to the previous tree. We do
Expand Down
12 changes: 12 additions & 0 deletions test/browser/components.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,18 @@ describe('Components', () => {
expect(scratch.innerHTML).to.equal('42');
});

it('should render a new String()', () => {
class ConstructedStringComponent extends Component {
render() {
/* eslint-disable no-new-wrappers */
return new String('Hi from a constructed string!');
}
}

render(<ConstructedStringComponent />, scratch);
expect(scratch.innerHTML).to.equal('Hi from a constructed string!');
});

it('should render null as empty string', () => {
class NullComponent extends Component {
render() {
Expand Down

0 comments on commit e866710

Please sign in to comment.