fix: 🐛 get deps info from slot

This commit is contained in:
春希 2020-07-28 13:22:44 +08:00
parent 23bc6214d6
commit 6c3ae36bca

View File

@ -8,12 +8,14 @@ import {
CodePiece, CodePiece,
HandlerSet, HandlerSet,
ExtGeneratorPlugin, ExtGeneratorPlugin,
IJSSlot,
INodeGeneratorConfig, INodeGeneratorConfig,
INodeGeneratorContext, INodeGeneratorContext,
NodeGenerator, NodeGenerator,
} from '../types'; } from '../types';
import { generateCompositeType } from './compositeType'; import { generateCompositeType } from './compositeType';
import { generateExpression, isJsExpression } from './jsExpression'; import { generateExpression, isJsExpression } from './jsExpression';
import { isJsSlot } from './jsSlot';
// tslint:disable-next-line: no-empty // tslint:disable-next-line: no-empty
const noop = () => []; const noop = () => [];
@ -50,6 +52,17 @@ export function handleSubNodes<T>(
const childRes = handleSubNodes(children.children, handlers, opt); const childRes = handleSubNodes(children.children, handlers, opt);
curRes = curRes.concat(childRes || []); curRes = curRes.concat(childRes || []);
} }
if (children.props) {
Object.keys(children.props)
.filter((propName) => isJsSlot(children.props[propName]))
.forEach((propName) => {
const soltVals = (children.props[propName] as IJSSlot).value;
(soltVals || []).forEach((soltVal) => {
const childRes = handleSubNodes(soltVal, handlers, opt);
curRes = curRes.concat(childRes || []);
});
});
}
return curRes; return curRes;
} }
} }