Merge branch 'fix/checkId-node' into 'release/1.0.0'

fix: checkId 需要传递



See merge request !1007574
This commit is contained in:
力皓 2020-10-13 10:12:14 +08:00
commit 571883e6ed
3 changed files with 5 additions and 5 deletions

View File

@ -222,7 +222,7 @@ export class DocumentModel {
} }
} }
if (!node) { if (!node) {
node = new Node(this, schema); node = new Node(this, schema, { checkId });
// will add // will add
// todo: this.activeNodes?.push(node); // todo: this.activeNodes?.push(node);
} }

View File

@ -11,9 +11,9 @@ export class NodeChildren {
private emitter = new EventEmitter(); private emitter = new EventEmitter();
constructor(readonly owner: ParentalNode, data: NodeData | NodeData[]) { constructor(readonly owner: ParentalNode, data: NodeData | NodeData[], options: any = {}) {
this.children = (Array.isArray(data) ? data : [data]).map(child => { this.children = (Array.isArray(data) ? data : [data]).map(child => {
return this.owner.document.createNode(child); return this.owner.document.createNode(child, options.checkId);
}); });
} }

View File

@ -154,7 +154,7 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
readonly settingEntry: SettingTopEntry; readonly settingEntry: SettingTopEntry;
constructor(readonly document: DocumentModel, nodeSchema: Schema) { constructor(readonly document: DocumentModel, nodeSchema: Schema, options: any = {}) {
const { componentName, id, children, props, ...extras } = nodeSchema; const { componentName, id, children, props, ...extras } = nodeSchema;
this.id = id || document.nextId(); this.id = id || document.nextId();
this.componentName = componentName; this.componentName = componentName;
@ -167,7 +167,7 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
// import 是为了使用钩子返回的值,并非完全幂等的操作,部分行为执行两次会有 bug // import 是为了使用钩子返回的值,并非完全幂等的操作,部分行为执行两次会有 bug
// 所以在 props 里会对 new / import 做一些区别化的解析 // 所以在 props 里会对 new / import 做一些区别化的解析
this.props = new Props(this, props, extras); this.props = new Props(this, props, extras);
this._children = new NodeChildren(this as ParentalNode, this.initialChildren(children)); this._children = new NodeChildren(this as ParentalNode, this.initialChildren(children), options);
this._children.internalInitParent(); this._children.internalInitParent();
this.props.import(this.upgradeProps(this.initProps(props || {})), this.upgradeProps(extras || {})); this.props.import(this.upgradeProps(this.initProps(props || {})), this.upgradeProps(extras || {}));
this.setupAutoruns(); this.setupAutoruns();