@tarojs/runtime 3.5.0-beta.1 → 3.5.0-beta.4

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.
@@ -1,4 +1,4 @@
1
- import { noop, isFunction, EMPTY_OBJ, hooks, toCamelCase, isObject, warn, isArray, ensure, toDashed, isUndefined, isString, internalComponents, controlledComponent, Events } from '@tarojs/shared';
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
- let id = 0;
186
- return () => (id++).toString();
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
- if (node.cssText !== '' && nodeName !== 'swiper-item') {
363
- data["st" /* Style */] = node.cssText;
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
 
@@ -413,6 +466,12 @@ class TaroEventTarget {
413
466
  }
414
467
  removeEventListener(type, handler) {
415
468
  type = type.toLowerCase();
469
+ if (type === 'regionchange') {
470
+ // map 组件的 regionchange 事件非常特殊,详情:https://github.com/NervJS/taro/issues/5766
471
+ this.removeEventListener('begin', handler);
472
+ this.removeEventListener('end', handler);
473
+ return;
474
+ }
416
475
  if (!handler) {
417
476
  return;
418
477
  }
@@ -442,23 +501,10 @@ class TaroNode extends TaroEventTarget {
442
501
  this.parentNode = null;
443
502
  this.childNodes = [];
444
503
  this.hydrate = (node) => () => hydrate(node);
445
- this.uid = `_n_${nodeId()}`; // dom 节点 id,开发者可修改
504
+ this.uid = '_' + nodeId(); // dom 节点 id,开发者可修改
446
505
  this.sid = this.uid; // dom 节点全局唯一 id,不可被修改
447
506
  eventSource.set(this.sid, this);
448
507
  }
449
- /**
450
- * like jQuery's $.empty()
451
- */
452
- _empty() {
453
- while (this.firstChild) {
454
- // Data Structure
455
- const child = this.firstChild;
456
- child.parentNode = null;
457
- this.childNodes.shift();
458
- // eventSource
459
- eventSource.removeNodeTree(child);
460
- }
461
- }
462
508
  updateChildNodes(isClean) {
463
509
  const cleanChildNodes = () => [];
464
510
  const rerenderChildNodes = () => {
@@ -518,23 +564,28 @@ class TaroNode extends TaroEventTarget {
518
564
  */
519
565
  // eslint-disable-next-line accessor-pairs
520
566
  set textContent(text) {
521
- const document = env.document;
522
- const newText = document.createTextNode(text);
523
- // @Todo: appendChild 会多触发一次
524
- MutationObserver.record({
525
- type: "childList" /* CHILD_LIST */,
526
- target: this,
527
- removedNodes: this.childNodes.slice(),
528
- addedNodes: text === '' ? [] : [newText]
529
- });
530
- 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
+ }
531
573
  if (text === '') {
532
574
  this.updateChildNodes(true);
533
575
  }
534
576
  else {
577
+ const newText = env.document.createTextNode(text);
578
+ addedNodes.push(newText);
535
579
  this.appendChild(newText);
536
580
  this.updateChildNodes();
537
581
  }
582
+ // @Todo: appendChild 会多触发一次
583
+ MutationObserver.record({
584
+ type: "childList" /* CHILD_LIST */,
585
+ target: this,
586
+ removedNodes,
587
+ addedNodes
588
+ });
538
589
  }
539
590
  /**
540
591
  * @doc https://developer.mozilla.org/zh-CN/docs/Web/API/Node/insertBefore
@@ -568,16 +619,31 @@ class TaroNode extends TaroEventTarget {
568
619
  this.childNodes.push(newChild);
569
620
  }
570
621
  // Serialization
571
- if (!refChild || isReplace) {
572
- // appendChild & replaceChild
573
- this.enqueueUpdate({
574
- path: newChild._path,
575
- value: this.hydrate(newChild)
576
- });
577
- }
578
- else {
579
- // insertBefore
580
- this.updateChildNodes();
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
+ }
581
647
  }
582
648
  MutationObserver.record({
583
649
  type: "childList" /* CHILD_LIST */,
@@ -652,7 +718,7 @@ class TaroNode extends TaroEventTarget {
652
718
  eventSource.removeNodeTree(child);
653
719
  }
654
720
  // Serialization
655
- if (doUpdate !== false) {
721
+ if (this._root && doUpdate !== false) {
656
722
  this.updateChildNodes();
657
723
  }
658
724
  return child;
@@ -859,30 +925,38 @@ combine('object', ['Fit', 'Position'], true);
859
925
  combine('box', ['DecorationBreak', 'Shadow', 'Sizing', 'Snap'], true);
860
926
  combine(WEBKIT, ['LineClamp', 'BoxOrient', 'TextFillColor', 'TextStroke', 'TextStrokeColor', 'TextStrokeWidth'], true);
861
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
+ }
862
945
  function setStyle(newVal, styleKey) {
946
+ process.env.NODE_ENV !== 'production' && warn(isString(newVal) && newVal.length > PROPERTY_THRESHOLD, `Style 属性 ${styleKey} 的值数据量过大,可能会影响渲染性能,考虑使用 CSS 类或其它方案替代。`);
863
947
  const old = this[styleKey];
864
- const oldCssTxt = this.cssText;
865
- if (newVal) {
866
- this._usedStyleProp.add(styleKey);
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];
867
954
  }
868
- process.env.NODE_ENV !== 'production' && warn(isString(newVal) && newVal.length > PROPERTY_THRESHOLD, `Style 属性 ${styleKey} 的值数据量过大,可能会影响渲染性能,考虑使用 CSS 类或其它方案替代。`);
869
- if (old !== newVal) {
955
+ else {
956
+ this._usedStyleProp.add(styleKey);
870
957
  this._value[styleKey] = newVal;
871
- this._element.enqueueUpdate({
872
- path: `${this._element._path}.${"st" /* Style */}`,
873
- value: this.cssText
874
- });
875
- // @Todo:
876
- // el.style.cssText = 'x: y;m: n'(Bug: 触发两次)
877
- // el.style.cssText = 'x: y'(正常)
878
- // el.style.x = y(正常)
879
- MutationObserver.record({
880
- type: "attributes" /* ATTRIBUTES */,
881
- target: this._element,
882
- attributeName: 'style',
883
- oldValue: oldCssTxt
884
- });
885
958
  }
959
+ !this._pending && enqueueUpdate(this);
886
960
  }
887
961
  function initStyle(ctor) {
888
962
  const properties = {};
@@ -890,7 +964,8 @@ function initStyle(ctor) {
890
964
  const styleKey = styleProperties[i];
891
965
  properties[styleKey] = {
892
966
  get() {
893
- return this._value[styleKey] || '';
967
+ const val = this._value[styleKey];
968
+ return isNull(val) || isUndefined(val) ? '' : val;
894
969
  },
895
970
  set(newVal) {
896
971
  setStyle.call(this, newVal, styleKey);
@@ -921,10 +996,12 @@ class Style {
921
996
  });
922
997
  }
923
998
  get cssText() {
999
+ if (!this._usedStyleProp.size)
1000
+ return '';
924
1001
  const texts = [];
925
1002
  this._usedStyleProp.forEach(key => {
926
1003
  const val = this[key];
927
- if (!val)
1004
+ if (isNull(val) || isUndefined(val))
928
1005
  return;
929
1006
  let styleName = isCssVariable(key) ? key : toDashed(key);
930
1007
  if (styleName.indexOf('webkit') === 0 || styleName.indexOf('Webkit') === 0) {
@@ -935,13 +1012,14 @@ class Style {
935
1012
  return texts.join(' ');
936
1013
  }
937
1014
  set cssText(str) {
938
- if (str == null) {
939
- str = '';
940
- }
1015
+ this._pending = true;
1016
+ recordCss(this);
941
1017
  this._usedStyleProp.forEach(prop => {
942
1018
  this.removeProperty(prop);
943
1019
  });
944
- if (str === '') {
1020
+ if (str === '' || isUndefined(str) || isNull(str)) {
1021
+ this._pending = false;
1022
+ enqueueUpdate(this);
945
1023
  return;
946
1024
  }
947
1025
  const rules = str.split(';');
@@ -958,6 +1036,8 @@ class Style {
958
1036
  }
959
1037
  this.setProperty(propName.trim(), val.trim());
960
1038
  }
1039
+ this._pending = false;
1040
+ enqueueUpdate(this);
961
1041
  }
962
1042
  setProperty(propertyName, value) {
963
1043
  if (propertyName[0] === '-') {
@@ -967,10 +1047,7 @@ class Style {
967
1047
  else {
968
1048
  propertyName = toCamelCase(propertyName);
969
1049
  }
970
- if (isUndefined(value)) {
971
- return;
972
- }
973
- if (value === null || value === '') {
1050
+ if (isNull(value) || isUndefined(value)) {
974
1051
  this.removeProperty(propertyName);
975
1052
  }
976
1053
  else {
@@ -983,8 +1060,7 @@ class Style {
983
1060
  return '';
984
1061
  }
985
1062
  const value = this[propertyName];
986
- this[propertyName] = '';
987
- this._usedStyleProp.delete(propertyName);
1063
+ this[propertyName] = undefined;
988
1064
  return value;
989
1065
  }
990
1066
  getPropertyValue(propertyName) {
@@ -1114,7 +1190,7 @@ class TaroElement extends TaroNode {
1114
1190
  this.setAttribute(FOCUS, false);
1115
1191
  }
1116
1192
  setAttribute(qualifiedName, value) {
1117
- process.env.NODE_ENV !== 'production' && warn(isString(value) && value.length > PROPERTY_THRESHOLD, `元素 ${this.nodeName} 的 属性 ${qualifiedName} 的值数据量过大,可能会影响渲染性能。考虑降低图片转为 base64 的阈值或在 CSS 中使用 base64。`);
1193
+ process.env.NODE_ENV !== 'production' && warn(isString(value) && value.length > PROPERTY_THRESHOLD, `元素 ${this.nodeName} 的 ${qualifiedName} 属性值数据量过大,可能会影响渲染性能。考虑降低图片转为 base64 的阈值或在 CSS 中使用 base64。`);
1118
1194
  const isPureView = this.nodeName === VIEW && !isHasExtractProp(this) && !this.isAnyEventBinded();
1119
1195
  if (qualifiedName !== STYLE) {
1120
1196
  MutationObserver.record({
@@ -1148,27 +1224,40 @@ class TaroElement extends TaroNode {
1148
1224
  }
1149
1225
  break;
1150
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;
1151
1236
  qualifiedName = shortcutAttr(qualifiedName);
1152
1237
  const payload = {
1153
- path: `${this._path}.${toCamelCase(qualifiedName)}`,
1238
+ path: `${_path}.${toCamelCase(qualifiedName)}`,
1154
1239
  value: isFunction(value) ? () => value : value
1155
1240
  };
1156
- 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
+ }
1157
1246
  this.enqueueUpdate(payload);
1158
1247
  if (this.nodeName === VIEW) {
1159
1248
  if (toCamelCase(qualifiedName) === CATCHMOVE) {
1160
1249
  // catchMove = true: catch-view
1161
1250
  // catchMove = false: view or static-view
1162
1251
  this.enqueueUpdate({
1163
- path: `${this._path}.${"nn" /* NodeName */}`,
1164
- value: value ? CATCH_VIEW : (this.isAnyEventBinded() ? VIEW : STATIC_VIEW)
1252
+ path: `${_path}.${"nn" /* NodeName */}`,
1253
+ value: value ? catchViewAlias : (this.isAnyEventBinded() ? viewAlias : staticViewAlias)
1165
1254
  });
1166
1255
  }
1167
1256
  else if (isPureView && isHasExtractProp(this)) {
1168
1257
  // pure-view => static-view
1169
1258
  this.enqueueUpdate({
1170
- path: `${this._path}.${"nn" /* NodeName */}`,
1171
- value: STATIC_VIEW
1259
+ path: `${_path}.${"nn" /* NodeName */}`,
1260
+ value: staticViewAlias
1172
1261
  });
1173
1262
  }
1174
1263
  }
@@ -1194,26 +1283,39 @@ class TaroElement extends TaroNode {
1194
1283
  }
1195
1284
  delete this.props[qualifiedName];
1196
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;
1197
1295
  qualifiedName = shortcutAttr(qualifiedName);
1198
1296
  const payload = {
1199
- path: `${this._path}.${toCamelCase(qualifiedName)}`,
1297
+ path: `${_path}.${toCamelCase(qualifiedName)}`,
1200
1298
  value: ''
1201
1299
  };
1202
- 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
+ }
1203
1305
  this.enqueueUpdate(payload);
1204
1306
  if (this.nodeName === VIEW) {
1205
1307
  if (toCamelCase(qualifiedName) === CATCHMOVE) {
1206
1308
  // catch-view => view or static-view or pure-view
1207
1309
  this.enqueueUpdate({
1208
- path: `${this._path}.${"nn" /* NodeName */}`,
1209
- value: this.isAnyEventBinded() ? VIEW : (isHasExtractProp(this) ? STATIC_VIEW : PURE_VIEW)
1310
+ path: `${_path}.${"nn" /* NodeName */}`,
1311
+ value: this.isAnyEventBinded() ? viewAlias : (isHasExtractProp(this) ? staticViewAlias : pureViewAlias)
1210
1312
  });
1211
1313
  }
1212
1314
  else if (isStaticView && !isHasExtractProp(this)) {
1213
1315
  // static-view => pure-view
1214
1316
  this.enqueueUpdate({
1215
- path: `${this._path}.${"nn" /* NodeName */}`,
1216
- value: PURE_VIEW
1317
+ path: `${_path}.${"nn" /* NodeName */}`,
1318
+ value: pureViewAlias
1217
1319
  });
1218
1320
  }
1219
1321
  }
@@ -1268,22 +1370,32 @@ class TaroElement extends TaroNode {
1268
1370
  addEventListener(type, handler, options) {
1269
1371
  const name = this.nodeName;
1270
1372
  const SPECIAL_NODES = hooks.call('getSpecialNodes');
1271
- if (!this.isAnyEventBinded() && SPECIAL_NODES.indexOf(name) > -1) {
1373
+ let sideEffect = true;
1374
+ if (isObject(options) && options.sideEffect === false) {
1375
+ sideEffect = false;
1376
+ delete options.sideEffect;
1377
+ }
1378
+ if (sideEffect !== false && !this.isAnyEventBinded() && SPECIAL_NODES.indexOf(name) > -1) {
1379
+ const componentsAlias = getComponentsAlias();
1380
+ const alias = componentsAlias[name]._num;
1272
1381
  this.enqueueUpdate({
1273
1382
  path: `${this._path}.${"nn" /* NodeName */}`,
1274
- value: name
1383
+ value: alias
1275
1384
  });
1276
1385
  }
1277
1386
  super.addEventListener(type, handler, options);
1278
1387
  }
1279
- removeEventListener(type, handler) {
1388
+ removeEventListener(type, handler, sideEffect = true) {
1280
1389
  super.removeEventListener(type, handler);
1281
1390
  const name = this.nodeName;
1282
1391
  const SPECIAL_NODES = hooks.call('getSpecialNodes');
1283
- if (!this.isAnyEventBinded() && SPECIAL_NODES.indexOf(name) > -1) {
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;
1284
1396
  this.enqueueUpdate({
1285
1397
  path: `${this._path}.${"nn" /* NodeName */}`,
1286
- value: isHasExtractProp(this) ? `static-${name}` : `pure-${name}`
1398
+ value: valueAlias
1287
1399
  });
1288
1400
  }
1289
1401
  }
@@ -2240,26 +2352,43 @@ class TaroEvent {
2240
2352
  }
2241
2353
  get target() {
2242
2354
  var _a, _b;
2243
- const target = Object.create(((_a = this.mpEvent) === null || _a === void 0 ? void 0 : _a.target) || null);
2244
- const element = env.document.getElementById(target.id);
2245
- target.dataset = element !== null ? element.dataset : EMPTY_OBJ;
2246
- for (const key in (_b = this.mpEvent) === null || _b === void 0 ? void 0 : _b.detail) {
2247
- target[key] = this.mpEvent.detail[key];
2355
+ const cacheTarget = this.cacheTarget;
2356
+ if (!cacheTarget) {
2357
+ const target = Object.create(((_a = this.mpEvent) === null || _a === void 0 ? void 0 : _a.target) || null);
2358
+ const element = env.document.getElementById(target.id);
2359
+ target.dataset = element !== null ? element.dataset : EMPTY_OBJ;
2360
+ for (const key in (_b = this.mpEvent) === null || _b === void 0 ? void 0 : _b.detail) {
2361
+ target[key] = this.mpEvent.detail[key];
2362
+ }
2363
+ this.cacheTarget = target;
2364
+ return target;
2365
+ }
2366
+ else {
2367
+ return cacheTarget;
2248
2368
  }
2249
- return target;
2250
2369
  }
2251
2370
  get currentTarget() {
2252
- var _a, _b;
2253
- const currentTarget = Object.create(((_a = this.mpEvent) === null || _a === void 0 ? void 0 : _a.currentTarget) || null);
2254
- const element = env.document.getElementById(currentTarget.id);
2255
- if (element === null) {
2256
- return this.target;
2371
+ var _a, _b, _c, _d;
2372
+ const cacheCurrentTarget = this.cacheCurrentTarget;
2373
+ if (!cacheCurrentTarget) {
2374
+ const doc = env.document;
2375
+ const currentTarget = Object.create(((_a = this.mpEvent) === null || _a === void 0 ? void 0 : _a.currentTarget) || null);
2376
+ const element = doc.getElementById(currentTarget.id);
2377
+ const targetElement = doc.getElementById(((_c = (_b = this.mpEvent) === null || _b === void 0 ? void 0 : _b.target) === null || _c === void 0 ? void 0 : _c.id) || null);
2378
+ if (element === null || (element && element === targetElement)) {
2379
+ this.cacheCurrentTarget = this.target;
2380
+ return this.target;
2381
+ }
2382
+ currentTarget.dataset = element.dataset;
2383
+ for (const key in (_d = this.mpEvent) === null || _d === void 0 ? void 0 : _d.detail) {
2384
+ currentTarget[key] = this.mpEvent.detail[key];
2385
+ }
2386
+ this.cacheCurrentTarget = currentTarget;
2387
+ return currentTarget;
2257
2388
  }
2258
- currentTarget.dataset = element.dataset;
2259
- for (const key in (_b = this.mpEvent) === null || _b === void 0 ? void 0 : _b.detail) {
2260
- currentTarget[key] = this.mpEvent.detail[key];
2389
+ else {
2390
+ return cacheCurrentTarget;
2261
2391
  }
2262
- return currentTarget;
2263
2392
  }
2264
2393
  }
2265
2394
  function createEvent(event, node) {
@@ -2847,6 +2976,9 @@ function createPageConfig(component, pageName, data, pageConfig) {
2847
2976
  onShow: getOnShowEventKey(id),
2848
2977
  onHide: getOnHideEventKey(id)
2849
2978
  };
2979
+ if (!isUndefined(page.exitState)) {
2980
+ Current.router.exitState = page.exitState;
2981
+ }
2850
2982
  }
2851
2983
  let loadResolver;
2852
2984
  let hasLoaded;