Skip to content

Commit

Permalink
Merge pull request #46 from preactjs/golf-fn
Browse files Browse the repository at this point in the history
Streamline vdom function signature
  • Loading branch information
marvinhagemeister authored Sep 1, 2020
2 parents 8934a8a + e5e076c commit 9aff394
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function connectedCallback() {
this._vdom = h(
ContextProvider,
{ ...this._props, context },
toVdom(this, true, this._vdomComponent)
toVdom(this, this._vdomComponent)
);
(this.hasAttribute('hydrate') ? hydrate : render)(this._vdom, this._root);
}
Expand Down Expand Up @@ -126,7 +126,7 @@ function Slot(props, context) {
return h('slot', { ...props, ref });
}

function toVdom(element, wrap, nodeName) {
function toVdom(element, nodeName) {
if (element.nodeType === 3) return element.data;
if (element.nodeType !== 1) return null;
let children = [],
Expand All @@ -142,7 +142,7 @@ function toVdom(element, wrap, nodeName) {
}

for (i = cn.length; i--; ) {
const vnode = toVdom(cn[i], false);
const vnode = toVdom(cn[i], null);
// Move slots correctly
const name = cn[i].slot;
if (name) {
Expand All @@ -153,6 +153,6 @@ function toVdom(element, wrap, nodeName) {
}

// Only wrap the topmost node with a slot
const wrappedChildren = wrap ? h(Slot, null, children) : children;
const wrappedChildren = nodeName ? h(Slot, null, children) : children;
return h(nodeName || element.nodeName.toLowerCase(), props, wrappedChildren);
}

0 comments on commit 9aff394

Please sign in to comment.