Supporting the ref-prop
This commit is contained in:
parent
f3597cbbb1
commit
029fe16b6d
@ -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;
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@ const VNODEPROP_EXCLUDE_DIRECT = {
|
||||
};
|
||||
const VNODEPROP_IGNORE = {
|
||||
['key']: true,
|
||||
['ref']: true
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user