@tarojs/runtime 3.6.9-alpha.12 → 3.6.9-alpha.15

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.
@@ -4,6 +4,7 @@ import { Style } from './style';
4
4
  import type { Attributes, Func } from '../interface';
5
5
  import type { TaroEvent } from './event';
6
6
  export declare class TaroElement extends TaroNode {
7
+ ctx?: any;
7
8
  tagName: string;
8
9
  props: Record<string, any>;
9
10
  style: Style;
@@ -18,6 +18,7 @@ export declare class TaroNode extends TaroEventTarget {
18
18
  constructor();
19
19
  private hydrate;
20
20
  private updateChildNodes;
21
+ private updateSingleChild;
21
22
  get _root(): TaroRootElement | null;
22
23
  protected findIndex(refChild: TaroNode): number;
23
24
  get _path(): string;
@@ -6,6 +6,7 @@ import type { TaroElement } from '../dom/element';
6
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
+ node?: TaroElement;
9
10
  $forceUpdate?(): void;
10
11
  $nextTick?(cb: () => void): void;
11
12
  $options: Instance;
@@ -77,6 +78,7 @@ interface Show {
77
78
  export interface AppInstance extends Show {
78
79
  componentDidShow?(options?: Record<string, unknown>): void;
79
80
  mount?(component: React.ComponentClass | ComponentOptions<VueCtor> | Vue3Component, id: string, cb: (...args: any[]) => void): void;
81
+ mount?(component: React.ComponentClass | ComponentOptions<VueCtor> | Vue3Component, id: string, getCtx: (...args: any[]) => void, cb: (...args: any[]) => void): void;
80
82
  onError?(error: string): void;
81
83
  onLaunch?(options?: Record<string, unknown>): void;
82
84
  onPageNotFound?(res: any): void;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import './dom-external';
2
+ import env from './env';
2
3
  export { hooks } from '@tarojs/shared';
3
4
  export { document } from './bom/document';
4
5
  export { getComputedStyle } from './bom/getComputedStyle';
@@ -18,9 +19,11 @@ export { Style } from './dom/style';
18
19
  export { SVGElement } from './dom/svg';
19
20
  export { TaroText } from './dom/text';
20
21
  export { MutationObserver } from './dom-external/mutation-observer';
22
+ export { env };
23
+ export * from './constants';
21
24
  export { Current, getCurrentInstance } from './current';
22
25
  export { eventSource } from './dom/event-source';
23
- export { addLeadingSlash, createComponentConfig, createPageConfig, createRecursiveComponentConfig, getPageInstance, getPath, injectPageInstance, removePageInstance, safeExecute, stringify } from './dsl/common';
26
+ export { addLeadingSlash, createComponentConfig, createPageConfig, createRecursiveComponentConfig, getOnHideEventKey, getOnReadyEventKey, getOnShowEventKey, getPageInstance, getPath, injectPageInstance, removePageInstance, safeExecute, stringify } from './dsl/common';
24
27
  export * from './emitter/emitter';
25
28
  export { hydrate } from './hydrate';
26
29
  export { nextTick } from './next-tick';
@@ -5,7 +5,6 @@ import { ComponentOptions, VNode } from "vue";
5
5
  import { Component as Vue3Component } from "@vue/runtime-core";
6
6
  import { Component, ComponentClass } from "react";
7
7
  import { CombinedVueInstance } from "vue/types/vue";
8
- declare let document: any;
9
8
  declare class ClassList {
10
9
  private el;
11
10
  private tokenList;
@@ -104,70 +103,6 @@ declare class TaroText extends TaroNode {
104
103
  set data(text: string);
105
104
  get data(): string;
106
105
  }
107
- // Taro 事件对象。以 Web 标准的事件对象为基础,加入小程序事件对象中携带的部分信息,并模拟实现事件冒泡。
108
- declare class TaroEvent {
109
- private cacheTarget;
110
- private cacheCurrentTarget;
111
- type: string;
112
- bubbles: boolean;
113
- cancelable: boolean;
114
- _stop: boolean;
115
- _end: boolean;
116
- defaultPrevented: boolean;
117
- // Mouse Event botton property, it's used in 3rd lib, like react-router. default 0 in general
118
- button: number;
119
- // timestamp can either be hi-res ( relative to page load) or low-res (relative to UNIX epoch)
120
- // here use hi-res timestamp
121
- timeStamp: number;
122
- mpEvent: MpEvent | undefined;
123
- constructor(type: string, opts: EventOptions, event?: MpEvent);
124
- stopPropagation(): void;
125
- stopImmediatePropagation(): void;
126
- preventDefault(): void;
127
- get target(): any;
128
- get currentTarget(): any;
129
- }
130
- declare function createEvent(event: MpEvent | string, node?: TaroElement): TaroEvent;
131
- // 小程序的事件代理回调函数
132
- declare function eventHandler(event: MpEvent): any;
133
- declare class FormElement extends TaroElement {
134
- get type(): string;
135
- set type(val: string);
136
- get value(): string | boolean | number | any[];
137
- set value(val: string | boolean | number | any[]);
138
- dispatchEvent(event: TaroEvent): boolean;
139
- }
140
- declare class TaroRootElement extends TaroElement {
141
- private updatePayloads;
142
- private updateCallbacks;
143
- pendingUpdate: boolean;
144
- ctx: null | MpInstance;
145
- constructor();
146
- get _path(): string;
147
- get _root(): TaroRootElement;
148
- enqueueUpdate(payload: UpdatePayload): void;
149
- performUpdate(initRender?: boolean, prerender?: Func): void;
150
- enqueueUpdateCallback(cb: Func, ctx?: Record<string, any>): void;
151
- flushUpdateCallback(): void;
152
- }
153
- declare class TaroDocument extends TaroElement {
154
- documentElement: TaroElement;
155
- head: TaroElement;
156
- body: TaroElement;
157
- createEvent: typeof createEvent;
158
- constructor();
159
- createElement(type: string): TaroElement | TaroRootElement | FormElement;
160
- // an ugly fake createElementNS to deal with @vue/runtime-dom's
161
- // support mounting app to svg container since vue@3.0.8
162
- createElementNS(_svgNS: string, type: string): TaroElement | TaroRootElement | FormElement;
163
- createTextNode(text: string): TaroText;
164
- getElementById<T extends TaroElement>(id: string | undefined | null): T | null;
165
- querySelector<T extends TaroElement>(query: string): T | null;
166
- querySelectorAll(): never[];
167
- // @TODO: @PERF: 在 hydrate 移除掉空的 node
168
- createComment(): TaroText;
169
- get defaultView(): any;
170
- }
171
106
  interface Node {
172
107
  type: string;
173
108
  }
@@ -207,6 +142,19 @@ declare class TaroEventTarget {
207
142
  removeEventListener(type: string, handler: EventHandler): void;
208
143
  isAnyEventBinded(): boolean;
209
144
  }
145
+ declare class TaroRootElement extends TaroElement {
146
+ private updatePayloads;
147
+ private updateCallbacks;
148
+ pendingUpdate: boolean;
149
+ ctx: null | MpInstance;
150
+ constructor();
151
+ get _path(): string;
152
+ get _root(): TaroRootElement;
153
+ enqueueUpdate(payload: UpdatePayload): void;
154
+ performUpdate(initRender?: boolean, prerender?: Func): void;
155
+ enqueueUpdateCallback(cb: Func, ctx?: Record<string, any>): void;
156
+ flushUpdateCallback(): void;
157
+ }
210
158
  interface RemoveChildOptions {
211
159
  cleanRef?: boolean;
212
160
  doUpdate?: boolean;
@@ -221,6 +169,7 @@ declare class TaroNode extends TaroEventTarget {
221
169
  constructor();
222
170
  private hydrate;
223
171
  private updateChildNodes;
172
+ private updateSingleChild;
224
173
  get _root(): TaroRootElement | null;
225
174
  protected findIndex(refChild: TaroNode): number;
226
175
  get _path(): string;
@@ -289,7 +238,34 @@ declare class Style {
289
238
  removeProperty(propertyName: string): string;
290
239
  getPropertyValue(propertyName: string): any;
291
240
  }
241
+ // Taro 事件对象。以 Web 标准的事件对象为基础,加入小程序事件对象中携带的部分信息,并模拟实现事件冒泡。
242
+ declare class TaroEvent {
243
+ private cacheTarget;
244
+ private cacheCurrentTarget;
245
+ type: string;
246
+ bubbles: boolean;
247
+ cancelable: boolean;
248
+ _stop: boolean;
249
+ _end: boolean;
250
+ defaultPrevented: boolean;
251
+ // Mouse Event botton property, it's used in 3rd lib, like react-router. default 0 in general
252
+ button: number;
253
+ // timestamp can either be hi-res ( relative to page load) or low-res (relative to UNIX epoch)
254
+ // here use hi-res timestamp
255
+ timeStamp: number;
256
+ mpEvent: MpEvent | undefined;
257
+ constructor(type: string, opts: EventOptions, event?: MpEvent);
258
+ stopPropagation(): void;
259
+ stopImmediatePropagation(): void;
260
+ preventDefault(): void;
261
+ get target(): any;
262
+ get currentTarget(): any;
263
+ }
264
+ declare function createEvent(event: MpEvent | string, node?: TaroElement): TaroEvent;
265
+ // 小程序的事件代理回调函数
266
+ declare function eventHandler(event: MpEvent): any;
292
267
  declare class TaroElement extends TaroNode {
268
+ ctx?: any;
293
269
  tagName: string;
294
270
  props: Record<string, any>;
295
271
  style: Style;
@@ -323,6 +299,37 @@ declare class TaroElement extends TaroNode {
323
299
  removeEventListener(type: any, handler: any, sideEffect?: boolean): void;
324
300
  static extend(methodName: string, options: Func | Record<string, any>): void;
325
301
  }
302
+ declare class FormElement extends TaroElement {
303
+ get type(): string;
304
+ set type(val: string);
305
+ get value(): string | boolean | number | any[];
306
+ set value(val: string | boolean | number | any[]);
307
+ dispatchEvent(event: TaroEvent): boolean;
308
+ }
309
+ declare class TaroDocument extends TaroElement {
310
+ documentElement: TaroElement;
311
+ head: TaroElement;
312
+ body: TaroElement;
313
+ createEvent: typeof createEvent;
314
+ constructor();
315
+ createElement(type: string): TaroElement | TaroRootElement | FormElement;
316
+ // an ugly fake createElementNS to deal with @vue/runtime-dom's
317
+ // support mounting app to svg container since vue@3.0.8
318
+ createElementNS(_svgNS: string, type: string): TaroElement | TaroRootElement | FormElement;
319
+ createTextNode(text: string): TaroText;
320
+ getElementById<T extends TaroElement>(id: string | undefined | null): T | null;
321
+ querySelector<T extends TaroElement>(query: string): T | null;
322
+ querySelectorAll(): never[];
323
+ // @TODO: @PERF: 在 hydrate 移除掉空的 node
324
+ createComment(): TaroText;
325
+ get defaultView(): any;
326
+ }
327
+ interface Env {
328
+ window: any;
329
+ document: TaroDocument;
330
+ }
331
+ declare const env: Env;
332
+ declare let document: any;
326
333
  declare function getComputedStyle(element: TaroElement): Style;
327
334
  declare const eventCenter: Events;
328
335
  type EventsType = typeof Events;
@@ -582,8 +589,67 @@ declare class MutationObserver {
582
589
  takeRecords(): MutationRecord[];
583
590
  static record(record: MutationRecord): void;
584
591
  }
592
+ declare const PROPERTY_THRESHOLD = 2046;
593
+ declare const TARO_RUNTIME = "Taro runtime";
594
+ declare const HOOKS_APP_ID = "taro-app";
595
+ declare const SET_DATA = "\u5C0F\u7A0B\u5E8F setData";
596
+ declare const PAGE_INIT = "\u9875\u9762\u521D\u59CB\u5316";
597
+ declare const ROOT_STR = "root";
598
+ declare const HTML = "html";
599
+ declare const HEAD = "head";
600
+ declare const BODY = "body";
601
+ declare const APP = "app";
602
+ declare const CONTAINER = "container";
603
+ declare const DOCUMENT_ELEMENT_NAME = "#document";
604
+ declare const DOCUMENT_FRAGMENT = "document-fragment";
605
+ declare const ID = "id";
606
+ declare const UID = "uid";
607
+ declare const CLASS = "class";
608
+ declare const STYLE = "style";
609
+ declare const FOCUS = "focus";
610
+ declare const VIEW = "view";
611
+ declare const STATIC_VIEW = "static-view";
612
+ declare const PURE_VIEW = "pure-view";
613
+ declare const PROPS = "props";
614
+ declare const DATASET = "dataset";
615
+ declare const OBJECT = "object";
616
+ declare const VALUE = "value";
617
+ declare const INPUT = "input";
618
+ declare const CHANGE = "change";
619
+ declare const CUSTOM_WRAPPER = "custom-wrapper";
620
+ declare const TARGET = "target";
621
+ declare const CURRENT_TARGET = "currentTarget";
622
+ declare const TYPE = "type";
623
+ declare const CONFIRM = "confirm";
624
+ declare const TIME_STAMP = "timeStamp";
625
+ declare const KEY_CODE = "keyCode";
626
+ declare const TOUCHMOVE = "touchmove";
627
+ declare const DATE = "Date";
628
+ declare const SET_TIMEOUT = "setTimeout";
629
+ declare const CATCHMOVE = "catchMove";
630
+ declare const CATCH_VIEW = "catch-view";
631
+ declare const COMMENT = "comment";
632
+ declare const ON_LOAD = "onLoad";
633
+ declare const ON_READY = "onReady";
634
+ declare const ON_SHOW = "onShow";
635
+ declare const ON_HIDE = "onHide";
636
+ declare const OPTIONS = "options";
637
+ declare const EXTERNAL_CLASSES = "externalClasses";
638
+ declare const EVENT_CALLBACK_RESULT = "e_result";
639
+ declare const BEHAVIORS = "behaviors";
640
+ declare const A = "a";
641
+ /**
642
+ * 页面上下文切换时的行为
643
+ */
644
+ declare enum CONTEXT_ACTIONS {
645
+ INIT = "0",
646
+ RESTORE = "1",
647
+ RECOVER = "2",
648
+ DESTORY = "3"
649
+ }
585
650
  interface Instance<T = Record<string, any>> extends Component<T>, Show, PageInstance {
586
651
  tid?: string;
652
+ node?: TaroElement;
587
653
  $forceUpdate?(): void;
588
654
  $nextTick?(cb: () => void): void;
589
655
  $options: Instance;
@@ -655,6 +721,7 @@ interface Show {
655
721
  interface AppInstance extends Show {
656
722
  componentDidShow?(options?: Record<string, unknown>): void;
657
723
  mount?(component: React.ComponentClass | ComponentOptions<VueCtor> | Vue3Component, id: string, cb: (...args: any[]) => void): void;
724
+ mount?(component: React.ComponentClass | ComponentOptions<VueCtor> | Vue3Component, id: string, getCtx: (...args: any[]) => void, cb: (...args: any[]) => void): void;
658
725
  onError?(error: string): void;
659
726
  onLaunch?(options?: Record<string, unknown>): void;
660
727
  onPageNotFound?(res: any): void;
@@ -693,6 +760,9 @@ declare function addLeadingSlash(path?: string): string;
693
760
  declare function safeExecute(path: string, lifecycle: string, ...args: unknown[]): any;
694
761
  declare function stringify(obj?: Record<string, unknown>): string;
695
762
  declare function getPath(id: string, options?: Record<string, unknown>): string;
763
+ declare function getOnReadyEventKey(path: string): string;
764
+ declare function getOnShowEventKey(path: string): string;
765
+ declare function getOnHideEventKey(path: string): string;
696
766
  declare function createPageConfig(component: any, pageName?: string, data?: Record<string, unknown>, pageConfig?: PageConfig): PageInstance;
697
767
  declare function createComponentConfig(component: React.ComponentClass, componentName?: string, data?: Record<string, unknown>): any;
698
768
  declare function createRecursiveComponentConfig(componentName?: string): any;
@@ -707,4 +777,4 @@ declare const nextTick: (cb: Func, ctx?: Record<string, any>) => void;
707
777
  declare const options: Options;
708
778
  declare const incrementId: () => () => string;
709
779
  export { hooks } from '@tarojs/shared';
710
- export { document, getComputedStyle, History, Location, nav as navigator, _caf as cancelAnimationFrame, now, _raf as requestAnimationFrame, parseUrl, URL, URLSearchParams, history, location, window, TaroElement, createEvent, eventHandler, TaroEvent, FormElement, TaroNode, TaroRootElement, Style, SVGElement, TaroText, MutationObserver, Current, getCurrentInstance, eventSource, addLeadingSlash, createComponentConfig, createPageConfig, createRecursiveComponentConfig, getPageInstance, getPath, injectPageInstance, removePageInstance, safeExecute, stringify, EventsType, eventCenter, Events, hydrate, nextTick, options, incrementId, Instance, VueAppInstance, VueInstance, PageProps, ReactPageComponent, ReactPageInstance, ReactAppInstance, PageLifeCycle, PageInstance, AppInstance, Attributes, EventOptions, MpEvent, EventListenerOptions, AddEventListenerOptions, EventHandler, MpInstance, MiniElementData, MiniData, HydratedData, UpdatePayloadValue, DataTree, UpdatePayload, Options$0 as Options, Func, Ctx };
780
+ export { document, getComputedStyle, History, Location, nav as navigator, _caf as cancelAnimationFrame, now, _raf as requestAnimationFrame, parseUrl, URL, URLSearchParams, history, location, window, TaroElement, createEvent, eventHandler, TaroEvent, FormElement, TaroNode, TaroRootElement, Style, SVGElement, TaroText, MutationObserver, env, PROPERTY_THRESHOLD, TARO_RUNTIME, HOOKS_APP_ID, SET_DATA, PAGE_INIT, ROOT_STR, HTML, HEAD, BODY, APP, CONTAINER, DOCUMENT_ELEMENT_NAME, DOCUMENT_FRAGMENT, ID, UID, CLASS, STYLE, FOCUS, VIEW, STATIC_VIEW, PURE_VIEW, PROPS, DATASET, OBJECT, VALUE, INPUT, CHANGE, CUSTOM_WRAPPER, TARGET, CURRENT_TARGET, TYPE, CONFIRM, TIME_STAMP, KEY_CODE, TOUCHMOVE, DATE, SET_TIMEOUT, CATCHMOVE, CATCH_VIEW, COMMENT, ON_LOAD, ON_READY, ON_SHOW, ON_HIDE, OPTIONS, EXTERNAL_CLASSES, EVENT_CALLBACK_RESULT, BEHAVIORS, A, CONTEXT_ACTIONS, Current, getCurrentInstance, eventSource, addLeadingSlash, createComponentConfig, createPageConfig, createRecursiveComponentConfig, getOnHideEventKey, getOnReadyEventKey, getOnShowEventKey, getPageInstance, getPath, injectPageInstance, removePageInstance, safeExecute, stringify, EventsType, eventCenter, Events, hydrate, nextTick, options, incrementId, Instance, VueAppInstance, VueInstance, PageProps, ReactPageComponent, ReactPageInstance, ReactAppInstance, PageLifeCycle, PageInstance, AppInstance, Attributes, EventOptions, MpEvent, EventListenerOptions, AddEventListenerOptions, EventHandler, MpInstance, MiniElementData, MiniData, HydratedData, UpdatePayloadValue, DataTree, UpdatePayload, Options$0 as Options, Func, Ctx };
@@ -2,6 +2,8 @@ import { noop, isFunction, getComponentsAlias as getComponentsAlias$1, internalC
2
2
  export { Events, hooks } from '@tarojs/shared';
3
3
 
4
4
  const PROPERTY_THRESHOLD = 2046;
5
+ const TARO_RUNTIME = 'Taro runtime';
6
+ const HOOKS_APP_ID = 'taro-app';
5
7
  const SET_DATA = '小程序 setData';
6
8
  const PAGE_INIT = '页面初始化';
7
9
  const ROOT_STR = 'root';
@@ -34,6 +36,8 @@ const CONFIRM = 'confirm';
34
36
  const TIME_STAMP = 'timeStamp';
35
37
  const KEY_CODE = 'keyCode';
36
38
  const TOUCHMOVE = 'touchmove';
39
+ const DATE = 'Date';
40
+ const SET_TIMEOUT = 'setTimeout';
37
41
  const CATCHMOVE = 'catchMove';
38
42
  const CATCH_VIEW = 'catch-view';
39
43
  const COMMENT = 'comment';
@@ -403,6 +407,7 @@ let componentsAlias;
403
407
  * it's a vnode traverser and modifier: that's exactly what Taro's doing in here.
404
408
  */
405
409
  function hydrate(node) {
410
+ var _a;
406
411
  if (!componentsAlias) {
407
412
  // 初始化 componentsAlias
408
413
  componentsAlias = getComponentsAlias();
@@ -415,7 +420,7 @@ function hydrate(node) {
415
420
  if (isText(node)) {
416
421
  return {
417
422
  ["v" /* Shortcuts.Text */]: node.nodeValue,
418
- ["nn" /* Shortcuts.NodeName */]: componentsAlias[nodeName]._num
423
+ ["nn" /* Shortcuts.NodeName */]: ((_a = componentsAlias[nodeName]) === null || _a === void 0 ? void 0 : _a._num) || '8'
419
424
  };
420
425
  }
421
426
  const data = {
@@ -573,6 +578,18 @@ class TaroNode extends TaroEventTarget {
573
578
  value: isClean ? cleanChildNodes : rerenderChildNodes
574
579
  });
575
580
  }
581
+ updateSingleChild(index) {
582
+ this.childNodes.forEach((child, childIndex) => {
583
+ if (isComment(child))
584
+ return;
585
+ if (index && childIndex < index)
586
+ return;
587
+ this.enqueueUpdate({
588
+ path: child._path,
589
+ value: this.hydrate(child)
590
+ });
591
+ });
592
+ }
576
593
  get _root() {
577
594
  var _a;
578
595
  return ((_a = this.parentNode) === null || _a === void 0 ? void 0 : _a._root) || null;
@@ -664,22 +681,24 @@ class TaroNode extends TaroEventTarget {
664
681
  // - cleanRef: false (No need to clean eventSource, because newChild is about to be inserted)
665
682
  // - update: true (Need to update parent.childNodes, because parent.childNodes is reordered)
666
683
  newChild.remove({ cleanRef: false });
684
+ let index = 0;
667
685
  // Data structure
668
686
  newChild.parentNode = this;
669
687
  if (refChild) {
670
688
  // insertBefore & replaceChild
671
- const index = this.findIndex(refChild);
689
+ index = this.findIndex(refChild);
672
690
  this.childNodes.splice(index, 0, newChild);
673
691
  }
674
692
  else {
675
693
  // appendChild
676
694
  this.childNodes.push(newChild);
677
695
  }
696
+ const childNodesLength = this.childNodes.length;
678
697
  // Serialization
679
698
  if (this._root) {
680
699
  if (!refChild) {
681
700
  // appendChild
682
- const isOnlyChild = this.childNodes.length === 1;
701
+ const isOnlyChild = childNodesLength === 1;
683
702
  if (isOnlyChild) {
684
703
  this.updateChildNodes();
685
704
  }
@@ -698,8 +717,26 @@ class TaroNode extends TaroEventTarget {
698
717
  });
699
718
  }
700
719
  else {
701
- // insertBefore
702
- this.updateChildNodes();
720
+ // insertBefore 有两种更新模式
721
+ // 比方说有 A B C 三个节点,现在要在 C 前插入 D
722
+ // 1. 插入 D,然后更新整个父节点的 childNodes 数组
723
+ // setData({ cn: [A, B, D, C] })
724
+ // 2. 插入 D,然后更新 D 以及 D 之后每个节点的数据
725
+ // setData ({
726
+ // cn.[2]: D,
727
+ // cn.[3]: C,
728
+ // })
729
+ // 由于微信解析 ’cn.[2]‘ 这些路径的时候也需要消耗时间,
730
+ // 所以根据 insertBefore 插入的位置来做不同的处理
731
+ const mark = childNodesLength * 2 / 3;
732
+ if (mark > index) {
733
+ // 如果 insertBefore 的位置在 childNodes 的 2/3 前,则为了避免解析路径消耗过多的时间,采用第一种方式
734
+ this.updateChildNodes();
735
+ }
736
+ else {
737
+ // 如果 insertBefore 的位置在 childNodes 的 2/3 之后,则采用第二种方式,避免 childNodes 的全量更新
738
+ this.updateSingleChild(index);
739
+ }
703
740
  }
704
741
  }
705
742
  MutationObserver.record({
@@ -2430,13 +2467,13 @@ class TaroEvent {
2430
2467
  this.defaultPrevented = true;
2431
2468
  }
2432
2469
  get target() {
2433
- var _a, _b;
2470
+ var _a, _b, _c;
2434
2471
  const cacheTarget = this.cacheTarget;
2435
2472
  if (!cacheTarget) {
2436
2473
  const target = Object.create(((_a = this.mpEvent) === null || _a === void 0 ? void 0 : _a.target) || null);
2437
- const element = env.document.getElementById(target.id);
2474
+ const element = env.document.getElementById(((_b = target.dataset) === null || _b === void 0 ? void 0 : _b.sid) || target.id || null);
2438
2475
  target.dataset = element !== null ? element.dataset : EMPTY_OBJ;
2439
- for (const key in (_b = this.mpEvent) === null || _b === void 0 ? void 0 : _b.detail) {
2476
+ for (const key in (_c = this.mpEvent) === null || _c === void 0 ? void 0 : _c.detail) {
2440
2477
  target[key] = this.mpEvent.detail[key];
2441
2478
  }
2442
2479
  this.cacheTarget = target;
@@ -2447,19 +2484,19 @@ class TaroEvent {
2447
2484
  }
2448
2485
  }
2449
2486
  get currentTarget() {
2450
- var _a, _b, _c, _d;
2487
+ var _a, _b, _c, _d, _e, _f, _g, _h;
2451
2488
  const cacheCurrentTarget = this.cacheCurrentTarget;
2452
2489
  if (!cacheCurrentTarget) {
2453
2490
  const doc = env.document;
2454
2491
  const currentTarget = Object.create(((_a = this.mpEvent) === null || _a === void 0 ? void 0 : _a.currentTarget) || null);
2455
- const element = doc.getElementById(currentTarget.id);
2456
- 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);
2492
+ const element = doc.getElementById(((_b = currentTarget.dataset) === null || _b === void 0 ? void 0 : _b.sid) || currentTarget.id || null);
2493
+ const targetElement = doc.getElementById(((_e = (_d = (_c = this.mpEvent) === null || _c === void 0 ? void 0 : _c.target) === null || _d === void 0 ? void 0 : _d.dataset) === null || _e === void 0 ? void 0 : _e.sid) || ((_g = (_f = this.mpEvent) === null || _f === void 0 ? void 0 : _f.target) === null || _g === void 0 ? void 0 : _g.id) || null);
2457
2494
  if (element === null || (element && element === targetElement)) {
2458
2495
  this.cacheCurrentTarget = this.target;
2459
2496
  return this.target;
2460
2497
  }
2461
2498
  currentTarget.dataset = element.dataset;
2462
- for (const key in (_d = this.mpEvent) === null || _d === void 0 ? void 0 : _d.detail) {
2499
+ for (const key in (_h = this.mpEvent) === null || _h === void 0 ? void 0 : _h.detail) {
2463
2500
  currentTarget[key] = this.mpEvent.detail[key];
2464
2501
  }
2465
2502
  this.cacheCurrentTarget = currentTarget;
@@ -3206,9 +3243,6 @@ class AnchorElement extends TaroElement {
3206
3243
  }
3207
3244
  }
3208
3245
 
3209
- class CustomWrapperElement extends TaroElement {
3210
- }
3211
-
3212
3246
  class TaroDocument extends TaroElement {
3213
3247
  constructor() {
3214
3248
  super();
@@ -3229,9 +3263,6 @@ class TaroDocument extends TaroElement {
3229
3263
  case nodeName === A:
3230
3264
  element = new AnchorElement();
3231
3265
  break;
3232
- case nodeName === CUSTOM_WRAPPER:
3233
- element = new CustomWrapperElement();
3234
- break;
3235
3266
  default:
3236
3267
  element = new TaroElement();
3237
3268
  break;
@@ -4062,7 +4093,8 @@ function createComponentConfig(component, componentName, data) {
4062
4093
  [ATTACHED]() {
4063
4094
  var _a;
4064
4095
  perf.start(PAGE_INIT);
4065
- const path = getPath(id, { id: ((_a = this.getPageId) === null || _a === void 0 ? void 0 : _a.call(this)) || pageId() });
4096
+ this.pageIdCache = ((_a = this.getPageId) === null || _a === void 0 ? void 0 : _a.call(this)) || pageId();
4097
+ const path = getPath(id, { id: this.pageIdCache });
4066
4098
  Current.app.mount(component, path, () => {
4067
4099
  componentElement = env.document.getElementById(path);
4068
4100
  ensure(componentElement !== null, '没有找到组件实例。');
@@ -4075,7 +4107,7 @@ function createComponentConfig(component, componentName, data) {
4075
4107
  });
4076
4108
  },
4077
4109
  [DETACHED]() {
4078
- const path = getPath(id, { id: this.getPageId() });
4110
+ const path = getPath(id, { id: this.pageIdCache });
4079
4111
  Current.app.unmount(path, () => {
4080
4112
  instances.delete(path);
4081
4113
  if (componentElement) {
@@ -4186,5 +4218,5 @@ const nextTick = (cb, ctx) => {
4186
4218
  next();
4187
4219
  };
4188
4220
 
4189
- export { Current, FormElement, History, Location, MutationObserver, SVGElement, Style, TaroElement, TaroEvent, TaroNode, TaroRootElement, TaroText, URL, URLSearchParams, addLeadingSlash, _caf as cancelAnimationFrame, createComponentConfig, createEvent, createPageConfig, createRecursiveComponentConfig, document$1 as document, eventCenter, eventHandler, eventSource, getComputedStyle, getCurrentInstance, getPageInstance, getPath, history, hydrate, incrementId, injectPageInstance, location, nav as navigator, nextTick, now, options, parseUrl, removePageInstance, _raf as requestAnimationFrame, safeExecute, stringify, window$1 as window };
4221
+ export { A, APP, BEHAVIORS, BODY, CATCHMOVE, CATCH_VIEW, CHANGE, CLASS, COMMENT, CONFIRM, CONTAINER, CONTEXT_ACTIONS, CURRENT_TARGET, CUSTOM_WRAPPER, Current, DATASET, DATE, DOCUMENT_ELEMENT_NAME, DOCUMENT_FRAGMENT, EVENT_CALLBACK_RESULT, EXTERNAL_CLASSES, FOCUS, FormElement, HEAD, HOOKS_APP_ID, HTML, History, ID, INPUT, KEY_CODE, Location, MutationObserver, OBJECT, ON_HIDE, ON_LOAD, ON_READY, ON_SHOW, OPTIONS, PAGE_INIT, PROPERTY_THRESHOLD, PROPS, PURE_VIEW, ROOT_STR, SET_DATA, SET_TIMEOUT, STATIC_VIEW, STYLE, SVGElement, Style, TARGET, TARO_RUNTIME, TIME_STAMP, TOUCHMOVE, TYPE, TaroElement, TaroEvent, TaroNode, TaroRootElement, TaroText, UID, URL, URLSearchParams, VALUE, VIEW, addLeadingSlash, _caf as cancelAnimationFrame, createComponentConfig, createEvent, createPageConfig, createRecursiveComponentConfig, document$1 as document, env, eventCenter, eventHandler, eventSource, getComputedStyle, getCurrentInstance, getOnHideEventKey, getOnReadyEventKey, getOnShowEventKey, getPageInstance, getPath, history, hydrate, incrementId, injectPageInstance, location, nav as navigator, nextTick, now, options, parseUrl, removePageInstance, _raf as requestAnimationFrame, safeExecute, stringify, window$1 as window };
4190
4222
  //# sourceMappingURL=runtime.esm.js.map