提交 cc56e43e 编写于 作者: fxy060608's avatar fxy060608

chore: merge

......@@ -12201,7 +12201,10 @@
setText(text2) {
this.$.textContent = text2;
}
insert(parentNodeId, refNodeId) {
insert(parentNodeId, refNodeId, nodeJson) {
if (nodeJson) {
this.init(nodeJson, false);
}
var node = this.$;
var parentNode = $(parentNodeId);
if (refNodeId === -1) {
......@@ -12450,6 +12453,7 @@
this.insert(parentNodeId, refNodeId);
}
init(nodeJson) {
var isCreate = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
if (hasOwn$1(nodeJson, "a")) {
this.setAttrs(nodeJson.a);
}
......@@ -12463,12 +12467,14 @@
this.addWxsEvents(nodeJson.w);
}
super.init(nodeJson);
watch(this.$props, () => {
queuePostActionJob(this._update, JOB_PRIORITY_UPDATE);
}, {
flush: "sync"
});
this.update(true);
if (isCreate) {
watch(this.$props, () => {
queuePostActionJob(this._update, JOB_PRIORITY_UPDATE);
}, {
flush: "sync"
});
this.update(true);
}
}
setAttrs(attrs2) {
this.setWxsProps(attrs2);
......@@ -22901,7 +22907,7 @@
var parentNodeId = action[3];
return createElement(action[1], getDict(action[2]), parentNodeId === -1 ? 0 : parentNodeId, action[4], decodeNodeJson(getDict, action[5]));
case ACTION_TYPE_INSERT:
return $(action[1]).insert(action[2], action[3]);
return $(action[1]).insert(action[2], action[3], decodeNodeJson(getDict, action[4]));
case ACTION_TYPE_REMOVE:
return $(action[1]).remove();
case ACTION_TYPE_SET_ATTRIBUTE:
......
......@@ -17947,6 +17947,9 @@ class UniPageNode extends UniNode {
}
else {
// 部分手机上,create 和 insert 可能不在同一批次,被分批发送
if (extras) {
action[4] = extras;
}
this.updateActions.push(action);
// if ((process.env.NODE_ENV !== 'production')) {
// console.error(formatLog(`Insert`, action, 'not found createAction'))
......
......@@ -213,6 +213,9 @@ export default class UniPageNode extends UniNode implements IUniPageNode {
}
} else {
// 部分手机上,create 和 insert 可能不在同一批次,被分批发送
if (extras) {
action[4] = extras as UniNodeJSON
}
this.updateActions.push(action)
// if (__DEV__) {
// console.error(formatLog(`Insert`, action, 'not found createAction'))
......
......@@ -71,7 +71,7 @@ export class UniComponent extends UniNode {
// 延迟到insert之后,再flush,确保mounted等生命周期触发正常
flushPostFlushCbs()
}
init(nodeJson: Partial<UniNodeJSON>) {
init(nodeJson: Partial<UniNodeJSON>, isCreate: boolean = true) {
const { a, e, w } = nodeJson
if (a) {
// 初始化时,先提取 wxsProps,再 setAttr
......
......@@ -45,7 +45,7 @@ export class UniElement<T extends object> extends UniNode {
this.init(nodeJson)
this.insert(parentNodeId, refNodeId)
}
init(nodeJson: Partial<UniNodeJSON>) {
init(nodeJson: Partial<UniNodeJSON>, isCreate: boolean = true) {
if (hasOwn(nodeJson, 'a')) {
this.setAttrs(nodeJson.a!)
}
......@@ -59,14 +59,17 @@ export class UniElement<T extends object> extends UniNode {
this.addWxsEvents(nodeJson.w!)
}
super.init(nodeJson)
watch(
this.$props,
() => {
queuePostActionJob(this._update!, JOB_PRIORITY_UPDATE)
},
{ flush: 'sync' }
)
this.update(true)
// insert 的时候可能也会调用该 init
if (isCreate) {
watch(
this.$props,
() => {
queuePostActionJob(this._update!, JOB_PRIORITY_UPDATE)
},
{ flush: 'sync' }
)
this.update(true)
}
}
setAttrs(attrs: Record<string, any>) {
// 初始化时,先提取 wxsProps,再 setAttr
......
......@@ -36,7 +36,7 @@ export class UniNode {
parent.appendUniChild(this)
}
}
init(nodeJson: Partial<UniNodeJSON>) {
init(nodeJson: Partial<UniNodeJSON>, isCreate: boolean = true) {
if (hasOwn(nodeJson, 't')) {
this.$.textContent = nodeJson.t as string
}
......@@ -44,7 +44,15 @@ export class UniNode {
setText(text: string) {
this.$.textContent = text
}
insert(parentNodeId: number, refNodeId: number) {
insert(
parentNodeId: number,
refNodeId: number,
nodeJson?: Partial<UniNodeJSON>
) {
// 部分性能低的手机,create 和 insert 是分开的,而 nodeJson 可能随着 insert
if (nodeJson) {
this.init(nodeJson, false)
}
const node = this.$
const parentNode = $(parentNodeId)
if (refNodeId === -1) {
......
......@@ -68,7 +68,11 @@ function onPageUpdateSync(actions: (PageAction | DictAction)[]) {
decodeNodeJson(getDict, action[5] as UniNodeJSONMinify)
)
case ACTION_TYPE_INSERT:
return $(action[1]).insert(action[2], action[3])
return $(action[1]).insert(
action[2],
action[3],
decodeNodeJson(getDict, action[4] as UniNodeJSONMinify)
)
case ACTION_TYPE_REMOVE:
return $(action[1]).remove()
case ACTION_TYPE_SET_ATTRIBUTE:
......
......@@ -240,8 +240,15 @@ export declare const initCustomDatasetOnce: () => void;
* nodeId
* parentNodeId
* refNodeId
* nodeJson
*/
export declare type InsertAction = [typeof ACTION_TYPE_INSERT, number, number, number];
export declare type InsertAction = [
typeof ACTION_TYPE_INSERT,
number,
number,
number,
Partial<UniNodeJSON | UniNodeJSONMinify>?
];
export declare const invokeArrayFns: (fns: Function[], arg?: any) => any;
......
......@@ -58,8 +58,15 @@ export type CreateAction = [
* nodeId
* parentNodeId
* refNodeId
* nodeJson
*/
export type InsertAction = [typeof ACTION_TYPE_INSERT, number, number, number]
export type InsertAction = [
typeof ACTION_TYPE_INSERT,
number,
number,
number,
Partial<UniNodeJSON | UniNodeJSONMinify>?
]
/**
* nodeId
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册