@tarojs/runtime 3.5.0-beta.2 → 3.5.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/current.d.ts +1 -0
- package/dist/dom/node.d.ts +1 -5
- package/dist/dom/root.d.ts +1 -1
- package/dist/dom/style.d.ts +1 -0
- package/dist/dsl/instance.d.ts +4 -2
- package/dist/interface/hydrate.d.ts +1 -0
- package/dist/runtime.esm.js +190 -87
- package/dist/runtime.esm.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/package.json +3 -3
package/dist/current.d.ts
CHANGED
package/dist/dom/node.d.ts
CHANGED
|
@@ -17,12 +17,8 @@ export declare class TaroNode extends TaroEventTarget {
|
|
|
17
17
|
childNodes: TaroNode[];
|
|
18
18
|
constructor();
|
|
19
19
|
private hydrate;
|
|
20
|
-
/**
|
|
21
|
-
* like jQuery's $.empty()
|
|
22
|
-
*/
|
|
23
|
-
private _empty;
|
|
24
20
|
private updateChildNodes;
|
|
25
|
-
|
|
21
|
+
get _root(): TaroRootElement | null;
|
|
26
22
|
protected findIndex(refChild: TaroNode): number;
|
|
27
23
|
get _path(): string;
|
|
28
24
|
get nextSibling(): TaroNode | null;
|
package/dist/dom/root.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare class TaroRootElement extends TaroElement {
|
|
|
7
7
|
ctx: null | MpInstance;
|
|
8
8
|
constructor();
|
|
9
9
|
get _path(): string;
|
|
10
|
-
|
|
10
|
+
get _root(): TaroRootElement;
|
|
11
11
|
enqueueUpdate(payload: UpdatePayload): void;
|
|
12
12
|
performUpdate(initRender?: boolean, prerender?: Func): void;
|
|
13
13
|
enqueueUpdateCallback(cb: Func, ctx?: Record<string, any>): void;
|
package/dist/dom/style.d.ts
CHANGED
package/dist/dsl/instance.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import type { Component as Vue3Component } from '@vue/runtime-core';
|
|
1
2
|
import type { Component, ComponentClass } from 'react';
|
|
2
3
|
import VueCtor, { ComponentOptions, VNode } from 'vue';
|
|
3
|
-
import type { Component as Vue3Component } from '@vue/runtime-core';
|
|
4
4
|
import type { CombinedVueInstance } from 'vue/types/vue';
|
|
5
|
-
import type { Func, MpEvent } from '../interface';
|
|
6
5
|
import type { TaroElement } from '../dom/element';
|
|
6
|
+
import type { Func, MpEvent } from '../interface';
|
|
7
7
|
export interface Instance<T = Record<string, any>> extends Component<T>, Show, PageInstance {
|
|
8
8
|
tid?: string;
|
|
9
9
|
$forceUpdate?(): void;
|
|
@@ -53,6 +53,7 @@ export interface PageLifeCycle extends Show {
|
|
|
53
53
|
onPullIntercept?(): void;
|
|
54
54
|
onShareTimeline?(): void;
|
|
55
55
|
onAddToFavorites?(): void;
|
|
56
|
+
onSaveExitState?(): void;
|
|
56
57
|
eh?(event: MpEvent): void;
|
|
57
58
|
onLoad?(options: Record<string, unknown>, cb?: Func): void;
|
|
58
59
|
onUnload?(): void;
|
|
@@ -79,6 +80,7 @@ export interface AppInstance extends Show {
|
|
|
79
80
|
onShow?(options?: Record<string, unknown>): void;
|
|
80
81
|
unmount?(id: string): void;
|
|
81
82
|
unmount?(id: string, cb: () => void): void;
|
|
83
|
+
onError?(error: string): void;
|
|
82
84
|
onPageNotFound?(res: any): void;
|
|
83
85
|
taroGlobalData?: Record<any, any>;
|
|
84
86
|
}
|
package/dist/runtime.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { noop, isFunction, EMPTY_OBJ, hooks, toCamelCase, isObject, warn, isArray, ensure, isNull, isUndefined, toDashed, isString,
|
|
1
|
+
import { noop, isFunction, getComponentsAlias as getComponentsAlias$1, internalComponents, EMPTY_OBJ, hooks, toCamelCase, isObject, warn, isArray, ensure, isNull, isUndefined, toDashed, isString, controlledComponent, Events } from '@tarojs/shared';
|
|
2
2
|
export { Events, hooks } from '@tarojs/shared';
|
|
3
3
|
|
|
4
4
|
const PROPERTY_THRESHOLD = 2046;
|
|
@@ -182,8 +182,33 @@ class MutationObserver {
|
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
const incrementId = () => {
|
|
185
|
-
|
|
186
|
-
|
|
185
|
+
const chatCodes = [];
|
|
186
|
+
// A-Z
|
|
187
|
+
for (let i = 65; i <= 90; i++) {
|
|
188
|
+
chatCodes.push(i);
|
|
189
|
+
}
|
|
190
|
+
// a-z
|
|
191
|
+
for (let i = 97; i <= 122; i++) {
|
|
192
|
+
chatCodes.push(i);
|
|
193
|
+
}
|
|
194
|
+
const chatCodesLen = chatCodes.length - 1;
|
|
195
|
+
const list = [0, 0];
|
|
196
|
+
return () => {
|
|
197
|
+
const target = list.map(item => chatCodes[item]);
|
|
198
|
+
const res = String.fromCharCode(...target);
|
|
199
|
+
let tailIdx = list.length - 1;
|
|
200
|
+
list[tailIdx]++;
|
|
201
|
+
while (list[tailIdx] > chatCodesLen) {
|
|
202
|
+
list[tailIdx] = 0;
|
|
203
|
+
tailIdx = tailIdx - 1;
|
|
204
|
+
if (tailIdx < 0) {
|
|
205
|
+
list.push(0);
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
list[tailIdx]++;
|
|
209
|
+
}
|
|
210
|
+
return res;
|
|
211
|
+
};
|
|
187
212
|
};
|
|
188
213
|
function isElement(node) {
|
|
189
214
|
return node.nodeType === 1 /* ELEMENT_NODE */;
|
|
@@ -237,6 +262,13 @@ function extend(ctor, methodName, options) {
|
|
|
237
262
|
};
|
|
238
263
|
}
|
|
239
264
|
Object.defineProperty(ctor.prototype, methodName, Object.assign({ configurable: true, enumerable: true }, options));
|
|
265
|
+
}
|
|
266
|
+
let componentsAlias$1;
|
|
267
|
+
function getComponentsAlias() {
|
|
268
|
+
if (!componentsAlias$1) {
|
|
269
|
+
componentsAlias$1 = getComponentsAlias$1(internalComponents);
|
|
270
|
+
}
|
|
271
|
+
return componentsAlias$1;
|
|
240
272
|
}
|
|
241
273
|
|
|
242
274
|
class ClassList extends Set {
|
|
@@ -305,6 +337,8 @@ const env = {
|
|
|
305
337
|
document: process.env.TARO_ENV === 'h5' ? document : EMPTY_OBJ
|
|
306
338
|
};
|
|
307
339
|
|
|
340
|
+
let SPECIAL_NODES;
|
|
341
|
+
let componentsAlias;
|
|
308
342
|
/**
|
|
309
343
|
* React also has a fancy function's name for this: `hydrate()`.
|
|
310
344
|
* You may have been heard `hydrate` as a SSR-related function,
|
|
@@ -312,19 +346,25 @@ const env = {
|
|
|
312
346
|
* it's a vnode traverser and modifier: that's exactly what Taro's doing in here.
|
|
313
347
|
*/
|
|
314
348
|
function hydrate(node) {
|
|
349
|
+
if (!componentsAlias) {
|
|
350
|
+
// 初始化 componentsAlias
|
|
351
|
+
componentsAlias = getComponentsAlias();
|
|
352
|
+
}
|
|
353
|
+
if (!SPECIAL_NODES) {
|
|
354
|
+
// 初始化 SPECIAL_NODES
|
|
355
|
+
SPECIAL_NODES = hooks.call('getSpecialNodes');
|
|
356
|
+
}
|
|
315
357
|
const nodeName = node.nodeName;
|
|
316
358
|
if (isText(node)) {
|
|
317
359
|
return {
|
|
318
360
|
["v" /* Text */]: node.nodeValue,
|
|
319
|
-
["nn" /* NodeName */]: nodeName
|
|
361
|
+
["nn" /* NodeName */]: componentsAlias[nodeName]._num
|
|
320
362
|
};
|
|
321
363
|
}
|
|
322
364
|
const data = {
|
|
323
365
|
["nn" /* NodeName */]: nodeName,
|
|
324
366
|
sid: node.sid
|
|
325
367
|
};
|
|
326
|
-
const { props } = node;
|
|
327
|
-
const SPECIAL_NODES = hooks.call('getSpecialNodes');
|
|
328
368
|
if (node.uid !== node.sid) {
|
|
329
369
|
data.uid = node.uid;
|
|
330
370
|
}
|
|
@@ -334,6 +374,7 @@ function hydrate(node) {
|
|
|
334
374
|
data["nn" /* NodeName */] = PURE_VIEW;
|
|
335
375
|
}
|
|
336
376
|
}
|
|
377
|
+
const { props } = node;
|
|
337
378
|
for (const prop in props) {
|
|
338
379
|
const propInCamelCase = toCamelCase(prop);
|
|
339
380
|
if (!prop.startsWith('data-') && // 在 node.dataset 的数据
|
|
@@ -359,10 +400,22 @@ function hydrate(node) {
|
|
|
359
400
|
if (node.className !== '') {
|
|
360
401
|
data["cl" /* Class */] = node.className;
|
|
361
402
|
}
|
|
362
|
-
|
|
363
|
-
|
|
403
|
+
const cssText = node.cssText;
|
|
404
|
+
if (cssText !== '' && nodeName !== 'swiper-item') {
|
|
405
|
+
data["st" /* Style */] = cssText;
|
|
364
406
|
}
|
|
365
407
|
hooks.call('modifyHydrateData', data);
|
|
408
|
+
const nn = data["nn" /* NodeName */];
|
|
409
|
+
const componentAlias = componentsAlias[nn];
|
|
410
|
+
if (componentAlias) {
|
|
411
|
+
data["nn" /* NodeName */] = componentAlias._num;
|
|
412
|
+
for (const prop in data) {
|
|
413
|
+
if (prop in componentAlias) {
|
|
414
|
+
data[componentAlias[prop]] = data[prop];
|
|
415
|
+
delete data[prop];
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
366
419
|
return data;
|
|
367
420
|
}
|
|
368
421
|
|
|
@@ -448,23 +501,10 @@ class TaroNode extends TaroEventTarget {
|
|
|
448
501
|
this.parentNode = null;
|
|
449
502
|
this.childNodes = [];
|
|
450
503
|
this.hydrate = (node) => () => hydrate(node);
|
|
451
|
-
this.uid =
|
|
504
|
+
this.uid = '_' + nodeId(); // dom 节点 id,开发者可修改
|
|
452
505
|
this.sid = this.uid; // dom 节点全局唯一 id,不可被修改
|
|
453
506
|
eventSource.set(this.sid, this);
|
|
454
507
|
}
|
|
455
|
-
/**
|
|
456
|
-
* like jQuery's $.empty()
|
|
457
|
-
*/
|
|
458
|
-
_empty() {
|
|
459
|
-
while (this.firstChild) {
|
|
460
|
-
// Data Structure
|
|
461
|
-
const child = this.firstChild;
|
|
462
|
-
child.parentNode = null;
|
|
463
|
-
this.childNodes.shift();
|
|
464
|
-
// eventSource
|
|
465
|
-
eventSource.removeNodeTree(child);
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
508
|
updateChildNodes(isClean) {
|
|
469
509
|
const cleanChildNodes = () => [];
|
|
470
510
|
const rerenderChildNodes = () => {
|
|
@@ -524,23 +564,28 @@ class TaroNode extends TaroEventTarget {
|
|
|
524
564
|
*/
|
|
525
565
|
// eslint-disable-next-line accessor-pairs
|
|
526
566
|
set textContent(text) {
|
|
527
|
-
const
|
|
528
|
-
const
|
|
529
|
-
//
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
removedNodes: this.childNodes.slice(),
|
|
534
|
-
addedNodes: text === '' ? [] : [newText]
|
|
535
|
-
});
|
|
536
|
-
this._empty();
|
|
567
|
+
const removedNodes = this.childNodes.slice();
|
|
568
|
+
const addedNodes = [];
|
|
569
|
+
// Handle old children' data structure & ref
|
|
570
|
+
while (this.firstChild) {
|
|
571
|
+
this.removeChild(this.firstChild, { doUpdate: false });
|
|
572
|
+
}
|
|
537
573
|
if (text === '') {
|
|
538
574
|
this.updateChildNodes(true);
|
|
539
575
|
}
|
|
540
576
|
else {
|
|
577
|
+
const newText = env.document.createTextNode(text);
|
|
578
|
+
addedNodes.push(newText);
|
|
541
579
|
this.appendChild(newText);
|
|
542
580
|
this.updateChildNodes();
|
|
543
581
|
}
|
|
582
|
+
// @Todo: appendChild 会多触发一次
|
|
583
|
+
MutationObserver.record({
|
|
584
|
+
type: "childList" /* CHILD_LIST */,
|
|
585
|
+
target: this,
|
|
586
|
+
removedNodes,
|
|
587
|
+
addedNodes
|
|
588
|
+
});
|
|
544
589
|
}
|
|
545
590
|
/**
|
|
546
591
|
* @doc https://developer.mozilla.org/zh-CN/docs/Web/API/Node/insertBefore
|
|
@@ -574,16 +619,31 @@ class TaroNode extends TaroEventTarget {
|
|
|
574
619
|
this.childNodes.push(newChild);
|
|
575
620
|
}
|
|
576
621
|
// Serialization
|
|
577
|
-
if (
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
622
|
+
if (this._root) {
|
|
623
|
+
if (!refChild) {
|
|
624
|
+
// appendChild
|
|
625
|
+
const isOnlyChild = this.childNodes.length === 1;
|
|
626
|
+
if (isOnlyChild) {
|
|
627
|
+
this.updateChildNodes();
|
|
628
|
+
}
|
|
629
|
+
else {
|
|
630
|
+
this.enqueueUpdate({
|
|
631
|
+
path: newChild._path,
|
|
632
|
+
value: this.hydrate(newChild)
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
else if (isReplace) {
|
|
637
|
+
// replaceChild
|
|
638
|
+
this.enqueueUpdate({
|
|
639
|
+
path: newChild._path,
|
|
640
|
+
value: this.hydrate(newChild)
|
|
641
|
+
});
|
|
642
|
+
}
|
|
643
|
+
else {
|
|
644
|
+
// insertBefore
|
|
645
|
+
this.updateChildNodes();
|
|
646
|
+
}
|
|
587
647
|
}
|
|
588
648
|
MutationObserver.record({
|
|
589
649
|
type: "childList" /* CHILD_LIST */,
|
|
@@ -658,7 +718,7 @@ class TaroNode extends TaroEventTarget {
|
|
|
658
718
|
eventSource.removeNodeTree(child);
|
|
659
719
|
}
|
|
660
720
|
// Serialization
|
|
661
|
-
if (doUpdate !== false) {
|
|
721
|
+
if (this._root && doUpdate !== false) {
|
|
662
722
|
this.updateChildNodes();
|
|
663
723
|
}
|
|
664
724
|
return child;
|
|
@@ -865,30 +925,38 @@ combine('object', ['Fit', 'Position'], true);
|
|
|
865
925
|
combine('box', ['DecorationBreak', 'Shadow', 'Sizing', 'Snap'], true);
|
|
866
926
|
combine(WEBKIT, ['LineClamp', 'BoxOrient', 'TextFillColor', 'TextStroke', 'TextStrokeColor', 'TextStrokeWidth'], true);
|
|
867
927
|
|
|
928
|
+
function recordCss(obj) {
|
|
929
|
+
MutationObserver.record({
|
|
930
|
+
type: "attributes" /* ATTRIBUTES */,
|
|
931
|
+
target: obj._element,
|
|
932
|
+
attributeName: 'style',
|
|
933
|
+
oldValue: obj.cssText
|
|
934
|
+
});
|
|
935
|
+
}
|
|
936
|
+
function enqueueUpdate(obj) {
|
|
937
|
+
const element = obj._element;
|
|
938
|
+
if (element._root) {
|
|
939
|
+
element.enqueueUpdate({
|
|
940
|
+
path: `${element._path}.${"st" /* Style */}`,
|
|
941
|
+
value: obj.cssText
|
|
942
|
+
});
|
|
943
|
+
}
|
|
944
|
+
}
|
|
868
945
|
function setStyle(newVal, styleKey) {
|
|
946
|
+
process.env.NODE_ENV !== 'production' && warn(isString(newVal) && newVal.length > PROPERTY_THRESHOLD, `Style 属性 ${styleKey} 的值数据量过大,可能会影响渲染性能,考虑使用 CSS 类或其它方案替代。`);
|
|
869
947
|
const old = this[styleKey];
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
948
|
+
if (old === newVal)
|
|
949
|
+
return;
|
|
950
|
+
!this._pending && recordCss(this);
|
|
951
|
+
if (isNull(newVal) || isUndefined(newVal)) {
|
|
952
|
+
this._usedStyleProp.delete(styleKey);
|
|
953
|
+
delete this._value[styleKey];
|
|
873
954
|
}
|
|
874
|
-
|
|
875
|
-
|
|
955
|
+
else {
|
|
956
|
+
this._usedStyleProp.add(styleKey);
|
|
876
957
|
this._value[styleKey] = newVal;
|
|
877
|
-
this._element.enqueueUpdate({
|
|
878
|
-
path: `${this._element._path}.${"st" /* Style */}`,
|
|
879
|
-
value: this.cssText
|
|
880
|
-
});
|
|
881
|
-
// @Todo:
|
|
882
|
-
// el.style.cssText = 'x: y;m: n'(Bug: 触发两次)
|
|
883
|
-
// el.style.cssText = 'x: y'(正常)
|
|
884
|
-
// el.style.x = y(正常)
|
|
885
|
-
MutationObserver.record({
|
|
886
|
-
type: "attributes" /* ATTRIBUTES */,
|
|
887
|
-
target: this._element,
|
|
888
|
-
attributeName: 'style',
|
|
889
|
-
oldValue: oldCssTxt
|
|
890
|
-
});
|
|
891
958
|
}
|
|
959
|
+
!this._pending && enqueueUpdate(this);
|
|
892
960
|
}
|
|
893
961
|
function initStyle(ctor) {
|
|
894
962
|
const properties = {};
|
|
@@ -928,6 +996,8 @@ class Style {
|
|
|
928
996
|
});
|
|
929
997
|
}
|
|
930
998
|
get cssText() {
|
|
999
|
+
if (!this._usedStyleProp.size)
|
|
1000
|
+
return '';
|
|
931
1001
|
const texts = [];
|
|
932
1002
|
this._usedStyleProp.forEach(key => {
|
|
933
1003
|
const val = this[key];
|
|
@@ -942,13 +1012,14 @@ class Style {
|
|
|
942
1012
|
return texts.join(' ');
|
|
943
1013
|
}
|
|
944
1014
|
set cssText(str) {
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
}
|
|
1015
|
+
this._pending = true;
|
|
1016
|
+
recordCss(this);
|
|
948
1017
|
this._usedStyleProp.forEach(prop => {
|
|
949
1018
|
this.removeProperty(prop);
|
|
950
1019
|
});
|
|
951
|
-
if (str === '') {
|
|
1020
|
+
if (str === '' || isUndefined(str) || isNull(str)) {
|
|
1021
|
+
this._pending = false;
|
|
1022
|
+
enqueueUpdate(this);
|
|
952
1023
|
return;
|
|
953
1024
|
}
|
|
954
1025
|
const rules = str.split(';');
|
|
@@ -965,6 +1036,8 @@ class Style {
|
|
|
965
1036
|
}
|
|
966
1037
|
this.setProperty(propName.trim(), val.trim());
|
|
967
1038
|
}
|
|
1039
|
+
this._pending = false;
|
|
1040
|
+
enqueueUpdate(this);
|
|
968
1041
|
}
|
|
969
1042
|
setProperty(propertyName, value) {
|
|
970
1043
|
if (propertyName[0] === '-') {
|
|
@@ -974,10 +1047,7 @@ class Style {
|
|
|
974
1047
|
else {
|
|
975
1048
|
propertyName = toCamelCase(propertyName);
|
|
976
1049
|
}
|
|
977
|
-
if (isUndefined(value)) {
|
|
978
|
-
return;
|
|
979
|
-
}
|
|
980
|
-
if (value === null || value === '') {
|
|
1050
|
+
if (isNull(value) || isUndefined(value)) {
|
|
981
1051
|
this.removeProperty(propertyName);
|
|
982
1052
|
}
|
|
983
1053
|
else {
|
|
@@ -990,8 +1060,7 @@ class Style {
|
|
|
990
1060
|
return '';
|
|
991
1061
|
}
|
|
992
1062
|
const value = this[propertyName];
|
|
993
|
-
this[propertyName] =
|
|
994
|
-
this._usedStyleProp.delete(propertyName);
|
|
1063
|
+
this[propertyName] = undefined;
|
|
995
1064
|
return value;
|
|
996
1065
|
}
|
|
997
1066
|
getPropertyValue(propertyName) {
|
|
@@ -1121,7 +1190,7 @@ class TaroElement extends TaroNode {
|
|
|
1121
1190
|
this.setAttribute(FOCUS, false);
|
|
1122
1191
|
}
|
|
1123
1192
|
setAttribute(qualifiedName, value) {
|
|
1124
|
-
process.env.NODE_ENV !== 'production' && warn(isString(value) && value.length > PROPERTY_THRESHOLD, `元素 ${this.nodeName} 的
|
|
1193
|
+
process.env.NODE_ENV !== 'production' && warn(isString(value) && value.length > PROPERTY_THRESHOLD, `元素 ${this.nodeName} 的 ${qualifiedName} 属性值数据量过大,可能会影响渲染性能。考虑降低图片转为 base64 的阈值或在 CSS 中使用 base64。`);
|
|
1125
1194
|
const isPureView = this.nodeName === VIEW && !isHasExtractProp(this) && !this.isAnyEventBinded();
|
|
1126
1195
|
if (qualifiedName !== STYLE) {
|
|
1127
1196
|
MutationObserver.record({
|
|
@@ -1155,27 +1224,40 @@ class TaroElement extends TaroNode {
|
|
|
1155
1224
|
}
|
|
1156
1225
|
break;
|
|
1157
1226
|
}
|
|
1227
|
+
// Serialization
|
|
1228
|
+
if (!this._root)
|
|
1229
|
+
return;
|
|
1230
|
+
const componentsAlias = getComponentsAlias();
|
|
1231
|
+
const _alias = componentsAlias[this.nodeName];
|
|
1232
|
+
const viewAlias = componentsAlias[VIEW]._num;
|
|
1233
|
+
const staticViewAlias = componentsAlias[STATIC_VIEW]._num;
|
|
1234
|
+
const catchViewAlias = componentsAlias[CATCH_VIEW]._num;
|
|
1235
|
+
const _path = this._path;
|
|
1158
1236
|
qualifiedName = shortcutAttr(qualifiedName);
|
|
1159
1237
|
const payload = {
|
|
1160
|
-
path: `${
|
|
1238
|
+
path: `${_path}.${toCamelCase(qualifiedName)}`,
|
|
1161
1239
|
value: isFunction(value) ? () => value : value
|
|
1162
1240
|
};
|
|
1163
|
-
hooks.call('modifySetAttrPayload', this, qualifiedName, payload);
|
|
1241
|
+
hooks.call('modifySetAttrPayload', this, qualifiedName, payload, componentsAlias);
|
|
1242
|
+
if (_alias) {
|
|
1243
|
+
const qualifiedNameAlias = _alias[qualifiedName] || qualifiedName;
|
|
1244
|
+
payload.path = `${_path}.${toCamelCase(qualifiedNameAlias)}`;
|
|
1245
|
+
}
|
|
1164
1246
|
this.enqueueUpdate(payload);
|
|
1165
1247
|
if (this.nodeName === VIEW) {
|
|
1166
1248
|
if (toCamelCase(qualifiedName) === CATCHMOVE) {
|
|
1167
1249
|
// catchMove = true: catch-view
|
|
1168
1250
|
// catchMove = false: view or static-view
|
|
1169
1251
|
this.enqueueUpdate({
|
|
1170
|
-
path: `${
|
|
1171
|
-
value: value ?
|
|
1252
|
+
path: `${_path}.${"nn" /* NodeName */}`,
|
|
1253
|
+
value: value ? catchViewAlias : (this.isAnyEventBinded() ? viewAlias : staticViewAlias)
|
|
1172
1254
|
});
|
|
1173
1255
|
}
|
|
1174
1256
|
else if (isPureView && isHasExtractProp(this)) {
|
|
1175
1257
|
// pure-view => static-view
|
|
1176
1258
|
this.enqueueUpdate({
|
|
1177
|
-
path: `${
|
|
1178
|
-
value:
|
|
1259
|
+
path: `${_path}.${"nn" /* NodeName */}`,
|
|
1260
|
+
value: staticViewAlias
|
|
1179
1261
|
});
|
|
1180
1262
|
}
|
|
1181
1263
|
}
|
|
@@ -1201,26 +1283,39 @@ class TaroElement extends TaroNode {
|
|
|
1201
1283
|
}
|
|
1202
1284
|
delete this.props[qualifiedName];
|
|
1203
1285
|
}
|
|
1286
|
+
// Serialization
|
|
1287
|
+
if (!this._root)
|
|
1288
|
+
return;
|
|
1289
|
+
const componentsAlias = getComponentsAlias();
|
|
1290
|
+
const _alias = componentsAlias[this.nodeName];
|
|
1291
|
+
const viewAlias = componentsAlias[VIEW]._num;
|
|
1292
|
+
const staticViewAlias = componentsAlias[STATIC_VIEW]._num;
|
|
1293
|
+
const pureViewAlias = componentsAlias[PURE_VIEW]._num;
|
|
1294
|
+
const _path = this._path;
|
|
1204
1295
|
qualifiedName = shortcutAttr(qualifiedName);
|
|
1205
1296
|
const payload = {
|
|
1206
|
-
path: `${
|
|
1297
|
+
path: `${_path}.${toCamelCase(qualifiedName)}`,
|
|
1207
1298
|
value: ''
|
|
1208
1299
|
};
|
|
1209
|
-
hooks.call('modifyRmAttrPayload', this, qualifiedName, payload);
|
|
1300
|
+
hooks.call('modifyRmAttrPayload', this, qualifiedName, payload, componentsAlias);
|
|
1301
|
+
if (_alias) {
|
|
1302
|
+
const qualifiedNameAlias = _alias[qualifiedName] || qualifiedName;
|
|
1303
|
+
payload.path = `${_path}.${toCamelCase(qualifiedNameAlias)}`;
|
|
1304
|
+
}
|
|
1210
1305
|
this.enqueueUpdate(payload);
|
|
1211
1306
|
if (this.nodeName === VIEW) {
|
|
1212
1307
|
if (toCamelCase(qualifiedName) === CATCHMOVE) {
|
|
1213
1308
|
// catch-view => view or static-view or pure-view
|
|
1214
1309
|
this.enqueueUpdate({
|
|
1215
|
-
path: `${
|
|
1216
|
-
value: this.isAnyEventBinded() ?
|
|
1310
|
+
path: `${_path}.${"nn" /* NodeName */}`,
|
|
1311
|
+
value: this.isAnyEventBinded() ? viewAlias : (isHasExtractProp(this) ? staticViewAlias : pureViewAlias)
|
|
1217
1312
|
});
|
|
1218
1313
|
}
|
|
1219
1314
|
else if (isStaticView && !isHasExtractProp(this)) {
|
|
1220
1315
|
// static-view => pure-view
|
|
1221
1316
|
this.enqueueUpdate({
|
|
1222
|
-
path: `${
|
|
1223
|
-
value:
|
|
1317
|
+
path: `${_path}.${"nn" /* NodeName */}`,
|
|
1318
|
+
value: pureViewAlias
|
|
1224
1319
|
});
|
|
1225
1320
|
}
|
|
1226
1321
|
}
|
|
@@ -1281,9 +1376,11 @@ class TaroElement extends TaroNode {
|
|
|
1281
1376
|
delete options.sideEffect;
|
|
1282
1377
|
}
|
|
1283
1378
|
if (sideEffect !== false && !this.isAnyEventBinded() && SPECIAL_NODES.indexOf(name) > -1) {
|
|
1379
|
+
const componentsAlias = getComponentsAlias();
|
|
1380
|
+
const alias = componentsAlias[name]._num;
|
|
1284
1381
|
this.enqueueUpdate({
|
|
1285
1382
|
path: `${this._path}.${"nn" /* NodeName */}`,
|
|
1286
|
-
value:
|
|
1383
|
+
value: alias
|
|
1287
1384
|
});
|
|
1288
1385
|
}
|
|
1289
1386
|
super.addEventListener(type, handler, options);
|
|
@@ -1293,9 +1390,12 @@ class TaroElement extends TaroNode {
|
|
|
1293
1390
|
const name = this.nodeName;
|
|
1294
1391
|
const SPECIAL_NODES = hooks.call('getSpecialNodes');
|
|
1295
1392
|
if (sideEffect !== false && !this.isAnyEventBinded() && SPECIAL_NODES.indexOf(name) > -1) {
|
|
1393
|
+
const componentsAlias = getComponentsAlias();
|
|
1394
|
+
const value = isHasExtractProp(this) ? `static-${name}` : `pure-${name}`;
|
|
1395
|
+
const valueAlias = componentsAlias[value]._num;
|
|
1296
1396
|
this.enqueueUpdate({
|
|
1297
1397
|
path: `${this._path}.${"nn" /* NodeName */}`,
|
|
1298
|
-
value:
|
|
1398
|
+
value: valueAlias
|
|
1299
1399
|
});
|
|
1300
1400
|
}
|
|
1301
1401
|
}
|
|
@@ -2859,6 +2959,9 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
2859
2959
|
onShow: getOnShowEventKey(id),
|
|
2860
2960
|
onHide: getOnHideEventKey(id)
|
|
2861
2961
|
};
|
|
2962
|
+
if (!isUndefined(page.exitState)) {
|
|
2963
|
+
Current.router.exitState = page.exitState;
|
|
2964
|
+
}
|
|
2862
2965
|
}
|
|
2863
2966
|
let loadResolver;
|
|
2864
2967
|
let hasLoaded;
|