Skip to content

Commit

Permalink
Merge branch 'master' into ts_ondblclick
Browse files Browse the repository at this point in the history
  • Loading branch information
robertknight committed May 21, 2017
2 parents b06ff84 + 465dacb commit 08b93e0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/h.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function h(nodeName, attributes) {
for (i=child.length; i--; ) stack.push(child[i]);
}
else {
if (child===true || child===false) child = null;
if (typeof child==='boolean') child = null;

if ((simple = typeof nodeName!=='function')) {
if (child==null) child = '';
Expand Down
12 changes: 7 additions & 5 deletions src/vdom/diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function idiff(dom, vnode, context, mountAll, componentRoot) {
prevSvgMode = isSvgMode;

// empty values (null, undefined, booleans) render as empty Text nodes
if (vnode==null || vnode===false || vnode===true) vnode = '';
if (vnode==null || typeof vnode==='boolean') vnode = '';


// Fast case: Strings & Numbers create/update Text nodes.
Expand Down Expand Up @@ -94,18 +94,20 @@ function idiff(dom, vnode, context, mountAll, componentRoot) {


// If the VNode represents a Component, perform a component diff:
if (typeof vnode.nodeName==='function') {
let vnodeName = vnode.nodeName;
if (typeof vnodeName==='function') {
return buildComponentFromVNode(dom, vnode, context, mountAll);
}


// Tracks entering and exiting SVG namespace when descending through the tree.
isSvgMode = vnode.nodeName==='svg' ? true : vnode.nodeName==='foreignObject' ? false : isSvgMode;
isSvgMode = vnodeName==='svg' ? true : vnodeName==='foreignObject' ? false : isSvgMode;


// If there's no existing element or it's the wrong type, create a new one:
if (!dom || !isNamedNode(dom, String(vnode.nodeName))) {
out = createNode(String(vnode.nodeName), isSvgMode);
vnodeName = String(vnodeName);
if (!dom || !isNamedNode(dom, vnodeName)) {
out = createNode(vnodeName, isSvgMode);

if (dom) {
// move children into the replacement node
Expand Down
9 changes: 9 additions & 0 deletions test/shared/h.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,13 @@ describe('h(jsx)', () => {
.with.property('children')
.that.deep.equals(['onetwothree']);
});

it('should not merge children of components', () => {
let Component = ({children}) => children;
let r = h(Component, null, 'x', 'y');

expect(r).to.be.an('object')
.with.property('children')
.that.deep.equals(['x', 'y']);
});
});

0 comments on commit 08b93e0

Please sign in to comment.