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

chore: merge

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