Supporting the ref-prop

This commit is contained in:
Miel Truyen 2019-11-15 23:26:52 +01:00
parent f3597cbbb1
commit 029fe16b6d
2 changed files with 9 additions and 0 deletions

View File

@ -68,6 +68,10 @@ export function render(vnode, opts = {}) {
if (!item.host) {
item.host = renderer.create(item);
newlyCreated = true;
if(item.vnode?.props?.ref){// If props specify a ref-function, queue it to be called at the end of the render
state.refs.push([item.vnode.props.ref,item.host]);
}
}
// Update the element
@ -231,5 +235,9 @@ export function render(vnode, opts = {}) {
if(!item.parent) newRoot = item.host;
}
}
for(let [refCb, refItem] of state.refs){
refCb(refItem);
}
return newRoot;
}

View File

@ -10,6 +10,7 @@ const VNODEPROP_EXCLUDE_DIRECT = {
};
const VNODEPROP_IGNORE = {
['key']: true,
['ref']: true
};
/**