@tarojs/react 4.0.0-beta.1 → 4.0.0-beta.100
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/LICENSE +17 -3
- package/dist/componentTree.d.ts +19 -0
- package/dist/constant.d.ts +7 -0
- package/dist/domInput.d.ts +12 -0
- package/dist/event.d.ts +13 -0
- package/dist/index.d.ts +25 -0
- package/dist/inputValueTracking.d.ts +3 -0
- package/dist/props.d.ts +5 -0
- package/dist/react.esm.js +169 -49
- package/dist/react.esm.js.map +1 -1
- package/dist/reconciler.d.ts +4 -0
- package/dist/render.d.ts +25 -0
- package/dist/workTags.d.ts +26 -0
- package/package.json +18 -17
- package/dist/index.js +0 -842
- package/dist/index.js.map +0 -1
package/LICENSE
CHANGED
|
@@ -154,7 +154,21 @@ See `/LICENSE` for details of the license.
|
|
|
154
154
|
|
|
155
155
|
==================
|
|
156
156
|
|
|
157
|
-
MIT (
|
|
158
|
-
The following files embed [
|
|
159
|
-
`/packages/taro-components
|
|
157
|
+
MIT (weui):
|
|
158
|
+
The following files embed [weui](https://github.com/Tencent/weui) MIT:
|
|
159
|
+
`/packages/taro-components/src/components/*.scss`
|
|
160
|
+
See `/LICENSE.txt` for details of the license.
|
|
161
|
+
|
|
162
|
+
==================
|
|
163
|
+
|
|
164
|
+
Apache-2.0 (intersection-observer):
|
|
165
|
+
The following files embed [intersection-observer](https://github.com/GoogleChromeLabs/intersection-observer) Apache-2.0:
|
|
166
|
+
`/packages/taro-api/src/polyfill/intersection-observer.ts`
|
|
167
|
+
See `/LICENSE.txt` for details of the license.
|
|
168
|
+
|
|
169
|
+
==================
|
|
170
|
+
|
|
171
|
+
MIT (babel-plugin-jsx-dom-expressions):
|
|
172
|
+
The following files embed [babel-plugin-jsx-dom-expressions](https://github.com/ryansolid/dom-expressions/blob/main/packages/babel-plugin-jsx-dom-expressions) MIT:
|
|
173
|
+
`/packages/babel-plugin-transform-solid-jsx/src/*`
|
|
160
174
|
See `/LICENSE` for details of the license.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { TaroElement, TaroText } from '@tarojs/runtime';
|
|
2
|
+
import type { Fiber } from 'react-reconciler';
|
|
3
|
+
import type { Props } from './props';
|
|
4
|
+
export declare function precacheFiberNode(hostInst: Fiber, node: TaroElement | TaroText): void;
|
|
5
|
+
export declare function markContainerAsRoot(hostRoot: Fiber, node: TaroElement | TaroText): void;
|
|
6
|
+
export declare function unmarkContainerAsRoot(node: TaroElement | TaroText): void;
|
|
7
|
+
export declare function isContainerMarkedAsRoot(node: TaroElement | TaroText): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Given a DOM node, return the ReactDOMComponent or ReactDOMTextComponent
|
|
10
|
+
* instance, or null if the node was not rendered by this React.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getInstanceFromNode(node: TaroElement | TaroText): Fiber | null;
|
|
13
|
+
/**
|
|
14
|
+
* Given a ReactDOMComponent or ReactDOMTextComponent, return the corresponding
|
|
15
|
+
* DOM node.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getNodeFromInstance(inst: Fiber): any;
|
|
18
|
+
export declare function getFiberCurrentPropsFromNode(node: TaroElement | TaroText): Props;
|
|
19
|
+
export declare function updateFiberProps(node: TaroElement | TaroText, props: Props): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const supportedInputTypes: {
|
|
2
|
+
[key: string]: boolean;
|
|
3
|
+
};
|
|
4
|
+
export declare function getEventPriority(domEventName: any): 1 | 4 | 16;
|
|
5
|
+
export declare const internalPropsKey: string;
|
|
6
|
+
export declare const internalInstanceKey: string;
|
|
7
|
+
export declare const internalContainerInstanceKey: string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Props } from './props';
|
|
2
|
+
import type { FormElement, TaroElement } from '@tarojs/runtime';
|
|
3
|
+
import type { RestoreType } from './event';
|
|
4
|
+
declare function updateInputWrapper(element: TaroElement, oldValue: RestoreType, props: Props): void;
|
|
5
|
+
export declare function getToStringValue(value: any): any;
|
|
6
|
+
export declare function toString(value: any): string;
|
|
7
|
+
export declare function updateWrapper(element: TaroElement, oldValue: RestoreType, props: Props): void;
|
|
8
|
+
export declare function setNodeValue(node: FormElement, oldValue: RestoreType, value: any, type?: string): void;
|
|
9
|
+
export declare function isTextInputElement(elem: TaroElement): boolean;
|
|
10
|
+
export declare const ReactDOMTextareaRestoreControlledState: typeof updateWrapper;
|
|
11
|
+
export declare const ReactDOMInputRestoreControlledState: typeof updateInputWrapper;
|
|
12
|
+
export {};
|
package/dist/event.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TaroElement, TaroEvent } from '@tarojs/runtime';
|
|
2
|
+
import type { Fiber } from 'react-reconciler';
|
|
3
|
+
export type RestoreType = string | number | boolean | any[];
|
|
4
|
+
interface RestoreItem {
|
|
5
|
+
target: TaroElement;
|
|
6
|
+
value: RestoreType;
|
|
7
|
+
}
|
|
8
|
+
export declare function getTargetInstForInputOrChangeEvent(e: TaroEvent, node: TaroElement): false | Fiber | undefined;
|
|
9
|
+
export declare function enqueueStateRestore(target: RestoreItem): void;
|
|
10
|
+
export declare function needsStateRestore(): boolean;
|
|
11
|
+
export declare function finishEventHandler(): void;
|
|
12
|
+
export declare function restoreStateIfNeeded(): void;
|
|
13
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { internalInstanceKey } from './constant';
|
|
2
|
+
import { createRoot, render } from './render';
|
|
3
|
+
import type { TaroElement } from '@tarojs/runtime';
|
|
4
|
+
import type { ReactNode } from 'react';
|
|
5
|
+
declare const unstable_batchedUpdates: (fn: any, a: any) => any;
|
|
6
|
+
declare function unmountComponentAtNode(dom: TaroElement): boolean;
|
|
7
|
+
declare function findDOMNode(comp?: TaroElement | ReactNode): string | number | boolean | TaroElement | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null;
|
|
8
|
+
declare function createPortal(children: ReactNode, containerInfo: TaroElement, key?: string): {
|
|
9
|
+
$$typeof: number | symbol;
|
|
10
|
+
key: string | null;
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
containerInfo: TaroElement;
|
|
13
|
+
implementation: null;
|
|
14
|
+
};
|
|
15
|
+
export { createPortal, createRoot, findDOMNode, internalInstanceKey, render, unmountComponentAtNode, unstable_batchedUpdates, };
|
|
16
|
+
declare const _default: {
|
|
17
|
+
render: typeof render;
|
|
18
|
+
createRoot: typeof createRoot;
|
|
19
|
+
unstable_batchedUpdates: (fn: any, a: any) => any;
|
|
20
|
+
unmountComponentAtNode: typeof unmountComponentAtNode;
|
|
21
|
+
findDOMNode: typeof findDOMNode;
|
|
22
|
+
createPortal: typeof createPortal;
|
|
23
|
+
internalInstanceKey: string;
|
|
24
|
+
};
|
|
25
|
+
export default _default;
|
package/dist/props.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type TaroElement } from '@tarojs/runtime';
|
|
2
|
+
export type Props = Record<string, unknown>;
|
|
3
|
+
export declare function updateProps(dom: TaroElement, oldProps: Props, newProps: Props): void;
|
|
4
|
+
export declare function updatePropsByPayload(dom: TaroElement, oldProps: Props, updatePayload: any[]): void;
|
|
5
|
+
export declare function getUpdatePayload(dom: TaroElement, oldProps: Props, newProps: Props): any[] | null;
|
package/dist/react.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isObject, isString, isFunction, capitalize, toCamelCase, internalComponents, isNumber, noop, isUndefined, isBoolean, hooks, ensure } from '@tarojs/shared';
|
|
2
2
|
import { FormElement, convertNumber2PX, document } from '@tarojs/runtime';
|
|
3
3
|
import Reconciler from 'react-reconciler';
|
|
4
4
|
import { DefaultEventPriority as DefaultEventPriority$1 } from 'react-reconciler/constants';
|
|
@@ -134,6 +134,10 @@ function getFiberCurrentPropsFromNode(node) {
|
|
|
134
134
|
}
|
|
135
135
|
function updateFiberProps(node, props) {
|
|
136
136
|
node[internalPropsKey] = props;
|
|
137
|
+
if (process.env.TARO_PLATFORM === 'harmony') {
|
|
138
|
+
// @ts-ignore
|
|
139
|
+
node.updateTextNode();
|
|
140
|
+
}
|
|
137
141
|
}
|
|
138
142
|
|
|
139
143
|
// 从 props 中,更新 input 组件的 value 值
|
|
@@ -173,10 +177,10 @@ function updateWrapper(element, oldValue, props) {
|
|
|
173
177
|
function setNodeValue(node, oldValue, value, type = 'string') {
|
|
174
178
|
if (value != null) {
|
|
175
179
|
if (type === 'number') {
|
|
176
|
-
if ((value === 0 && node.value === '')
|
|
180
|
+
if ((value === 0 && node.value === '')
|
|
177
181
|
// We explicitly want to coerce to number here if possible.
|
|
178
182
|
// eslint-disable-next-line
|
|
179
|
-
oldValue != value) {
|
|
183
|
+
|| oldValue != value) {
|
|
180
184
|
node.value = toString(value);
|
|
181
185
|
}
|
|
182
186
|
}
|
|
@@ -286,17 +290,30 @@ function isEventName(s) {
|
|
|
286
290
|
return s[0] === 'o' && s[1] === 'n';
|
|
287
291
|
}
|
|
288
292
|
function isEqual(obj1, obj2) {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
293
|
+
// 首先检查引用是否相同
|
|
294
|
+
if (obj1 === obj2) {
|
|
295
|
+
return true;
|
|
296
|
+
}
|
|
297
|
+
// 如果两者中有一个不是对象,或者为 null,直接返回 false
|
|
298
|
+
if (typeof obj1 !== 'object' || obj1 === null || typeof obj2 !== 'object' || obj2 === null) {
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
// 获取两个对象键的数组
|
|
302
|
+
const keys1 = Object.keys(obj1);
|
|
303
|
+
const keys2 = Object.keys(obj2);
|
|
304
|
+
// 如果键的数量不相同,对象显然不相等
|
|
305
|
+
if (keys1.length !== keys2.length) {
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
// 遍历对象的每个键,比较两个对象同一键的值
|
|
309
|
+
for (let i = 0; i < keys1.length; i++) {
|
|
310
|
+
const key = keys1[i];
|
|
311
|
+
if (obj1[key] !== obj2[key]) {
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
// 如果所有键的值都相等,返回 true
|
|
316
|
+
return true;
|
|
300
317
|
}
|
|
301
318
|
function updateProps(dom, oldProps, newProps) {
|
|
302
319
|
const updatePayload = getUpdatePayload(dom, oldProps, newProps);
|
|
@@ -305,11 +322,29 @@ function updateProps(dom, oldProps, newProps) {
|
|
|
305
322
|
}
|
|
306
323
|
}
|
|
307
324
|
function updatePropsByPayload(dom, oldProps, updatePayload) {
|
|
308
|
-
|
|
325
|
+
const handlers = [];
|
|
326
|
+
for (let i = 0; i < updatePayload.length; i += 2) {
|
|
327
|
+
// key, value 成对出现
|
|
309
328
|
const key = updatePayload[i];
|
|
310
329
|
const newProp = updatePayload[i + 1];
|
|
311
330
|
const oldProp = oldProps[key];
|
|
312
|
-
|
|
331
|
+
if (isHarmony) {
|
|
332
|
+
// 鸿蒙样式前置插入,防止覆盖style
|
|
333
|
+
if (key === '__hmStyle') {
|
|
334
|
+
handlers.splice(0, 0, () => setHarmonyStyle(dom, newProp, oldProp));
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
handlers.push(() => setProperty(dom, key, newProp, oldProp));
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
else {
|
|
341
|
+
setProperty(dom, key, newProp, oldProp);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
if (isHarmony) {
|
|
345
|
+
for (let i = 0; i < handlers.length; i++) {
|
|
346
|
+
handlers[i]();
|
|
347
|
+
}
|
|
313
348
|
}
|
|
314
349
|
}
|
|
315
350
|
function getUpdatePayload(dom, oldProps, newProps) {
|
|
@@ -323,6 +358,9 @@ function getUpdatePayload(dom, oldProps, newProps) {
|
|
|
323
358
|
const isFormElement = dom instanceof FormElement;
|
|
324
359
|
for (i in newProps) {
|
|
325
360
|
if (oldProps[i] !== newProps[i] || (isFormElement && i === 'value')) {
|
|
361
|
+
// 如果都是 style,且 style 里面的值相等,则无需记录到 payload 中
|
|
362
|
+
if (i === 'style' && isObject(oldProps[i]) && isObject(newProps[i]) && isEqual(oldProps[i], newProps[i]))
|
|
363
|
+
continue;
|
|
326
364
|
(updatePayload = updatePayload || []).push(i, newProps[i]);
|
|
327
365
|
}
|
|
328
366
|
}
|
|
@@ -357,29 +395,85 @@ function setEvent(dom, name, value, oldValue) {
|
|
|
357
395
|
}
|
|
358
396
|
}
|
|
359
397
|
function setStyle(style, key, value) {
|
|
360
|
-
if (key[0] === '-') {
|
|
361
|
-
// 适配鸿蒙
|
|
362
|
-
if (isHarmony) {
|
|
363
|
-
style.setProperty(key, value);
|
|
364
|
-
}
|
|
365
|
-
else {
|
|
366
|
-
style.setProperty(key, value.toString());
|
|
367
|
-
}
|
|
398
|
+
if (key[0] === '-' && !isHarmony) {
|
|
368
399
|
// css variables need not further judgment
|
|
400
|
+
style.setProperty(key, value.toString());
|
|
369
401
|
return;
|
|
370
402
|
}
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
403
|
+
style[key] =
|
|
404
|
+
isNumber(value) && IS_NON_DIMENSIONAL.test(key) === false
|
|
405
|
+
? (isHarmony ? value + 'px' : convertNumber2PX(value))
|
|
406
|
+
: value === null
|
|
407
|
+
? ''
|
|
408
|
+
: value;
|
|
409
|
+
}
|
|
410
|
+
// 鸿蒙样式特殊处理,需要在插入顺序中前置插入,防止覆盖了style
|
|
411
|
+
function setHarmonyStyle(dom, value, oldValue) {
|
|
412
|
+
// @ts-ignore
|
|
413
|
+
const style = dom._st.hmStyle; // __hmStyle是已经被处理过的鸿蒙样式,可以直接塞进hmStyle对象内
|
|
414
|
+
if (isObject(oldValue)) {
|
|
415
|
+
for (const i in oldValue) {
|
|
416
|
+
if (!(value && i in value)) {
|
|
417
|
+
// 鸿蒙伪类特殊处理
|
|
418
|
+
if (isHarmony) {
|
|
419
|
+
if (i === '::after' || i === '::before') {
|
|
420
|
+
setPseudo(dom, i, null);
|
|
421
|
+
}
|
|
422
|
+
else if (['::first-child', '::last-child', '::empty'].includes(i) || `${i}`.indexOf('::nth-child') === 0) {
|
|
423
|
+
// @ts-ignore
|
|
424
|
+
dom.set_pseudo_class(i, null);
|
|
425
|
+
}
|
|
426
|
+
else {
|
|
427
|
+
if (i === 'position' && oldValue[i] === 'fixed') {
|
|
428
|
+
// @ts-ignore
|
|
429
|
+
dom.setLayer(0);
|
|
430
|
+
}
|
|
431
|
+
else if (i === 'animationName') {
|
|
432
|
+
// @ts-ignore
|
|
433
|
+
dom.setAnimation(false);
|
|
434
|
+
}
|
|
435
|
+
style[i] = '';
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
else {
|
|
439
|
+
style[i] = '';
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
374
443
|
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
444
|
+
if (isObject(value)) {
|
|
445
|
+
for (const i in value) {
|
|
446
|
+
if (!oldValue || !isEqual(value[i], oldValue[i])) {
|
|
447
|
+
// 鸿蒙伪类特殊处理
|
|
448
|
+
if (isHarmony) {
|
|
449
|
+
if (i === '::after' || i === '::before') {
|
|
450
|
+
setPseudo(dom, i, value[i]);
|
|
451
|
+
}
|
|
452
|
+
else if (['::first-child', '::last-child', '::empty'].includes(i) || i.startsWith('::nth-child')) {
|
|
453
|
+
// @ts-ignore
|
|
454
|
+
dom.set_pseudo_class(i, value[i]);
|
|
455
|
+
}
|
|
456
|
+
else {
|
|
457
|
+
if (i === 'position') {
|
|
458
|
+
if (value[i] === 'fixed' || (value[i] !== 'fixed' && (oldValue === null || oldValue === void 0 ? void 0 : oldValue[i]))) {
|
|
459
|
+
// @ts-ignore
|
|
460
|
+
dom.setLayer(value[i] === 'fixed' ? 1 : 0);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
else if (i === 'animationName') {
|
|
464
|
+
// @ts-ignore
|
|
465
|
+
dom.setAnimation(true);
|
|
466
|
+
}
|
|
467
|
+
style[i] = value[i];
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
else {
|
|
471
|
+
style[i] = value[i];
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
}
|
|
382
475
|
}
|
|
476
|
+
dom.setAttribute('__hmStyle', value);
|
|
383
477
|
}
|
|
384
478
|
function setProperty(dom, name, value, oldValue) {
|
|
385
479
|
var _a, _b;
|
|
@@ -397,25 +491,29 @@ function setProperty(dom, name, value, oldValue) {
|
|
|
397
491
|
style.cssText = '';
|
|
398
492
|
oldValue = null;
|
|
399
493
|
}
|
|
400
|
-
let needUpdateAfterMoved = false;
|
|
401
494
|
if (isObject(oldValue)) {
|
|
402
495
|
for (const i in oldValue) {
|
|
403
496
|
if (!(value && i in value)) {
|
|
404
|
-
|
|
405
|
-
if (
|
|
406
|
-
|
|
497
|
+
// Harmony特殊处理
|
|
498
|
+
if (isHarmony && i === 'position' && oldValue[i] === 'fixed') {
|
|
499
|
+
// @ts-ignore
|
|
500
|
+
dom.setLayer(0);
|
|
407
501
|
}
|
|
502
|
+
setStyle(style, i, '');
|
|
408
503
|
}
|
|
409
504
|
}
|
|
410
|
-
if (needUpdateAfterMoved) {
|
|
411
|
-
updateDOMInstance(dom);
|
|
412
|
-
}
|
|
413
505
|
}
|
|
414
506
|
if (isObject(value)) {
|
|
415
507
|
for (const i in value) {
|
|
416
508
|
if (!oldValue || !isEqual(value[i], oldValue[i])) {
|
|
509
|
+
// Harmony特殊处理
|
|
510
|
+
if (isHarmony && i === 'position') {
|
|
511
|
+
if (value[i] === 'fixed' || (value[i] !== 'fixed' && (oldValue === null || oldValue === void 0 ? void 0 : oldValue[i]))) {
|
|
512
|
+
// @ts-ignore
|
|
513
|
+
dom.setLayer(value[i] === 'fixed' ? 1 : 0);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
417
516
|
setStyle(style, i, value[i]);
|
|
418
|
-
updateDOMInstance(dom);
|
|
419
517
|
}
|
|
420
518
|
}
|
|
421
519
|
}
|
|
@@ -436,14 +534,23 @@ function setProperty(dom, name, value, oldValue) {
|
|
|
436
534
|
else if (!isFunction(value)) {
|
|
437
535
|
if (value == null) {
|
|
438
536
|
dom.removeAttribute(name);
|
|
439
|
-
updateDOMInstance(dom, name);
|
|
440
537
|
}
|
|
441
538
|
else {
|
|
442
539
|
dom.setAttribute(name, value);
|
|
443
|
-
updateDOMInstance(dom, name);
|
|
444
540
|
}
|
|
445
541
|
}
|
|
446
542
|
}
|
|
543
|
+
// 设置鸿蒙伪类属性(特殊设置)
|
|
544
|
+
function setPseudo(dom, name, value) {
|
|
545
|
+
if (name === '::after') {
|
|
546
|
+
// @ts-ignore
|
|
547
|
+
dom.set_pseudo_after(value);
|
|
548
|
+
}
|
|
549
|
+
else if (name === '::before') {
|
|
550
|
+
// @ts-ignore
|
|
551
|
+
dom.set_pseudo_before(value);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
447
554
|
|
|
448
555
|
/* eslint-disable @typescript-eslint/indent */
|
|
449
556
|
const hostConfig = {
|
|
@@ -474,7 +581,15 @@ const hostConfig = {
|
|
|
474
581
|
parent.appendChild(child);
|
|
475
582
|
},
|
|
476
583
|
finalizeInitialChildren(dom, type, props) {
|
|
477
|
-
|
|
584
|
+
let newProps = props;
|
|
585
|
+
if (dom instanceof FormElement) {
|
|
586
|
+
const [defaultName, defaultKey] = ['switch', 'checkbox', 'radio'].includes(type) ? ['checked', 'defaultChecked'] : ['value', 'defaultValue'];
|
|
587
|
+
if (props.hasOwnProperty(defaultKey)) {
|
|
588
|
+
newProps = Object.assign(Object.assign({}, newProps), { [defaultName]: props[defaultKey] });
|
|
589
|
+
delete newProps[defaultKey];
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
updateProps(dom, {}, newProps); // 提前执行更新属性操作,Taro 在 Page 初始化后会立即从 dom 读取必要信息
|
|
478
593
|
if (type === 'input' || type === 'textarea') {
|
|
479
594
|
track(dom);
|
|
480
595
|
}
|
|
@@ -513,8 +628,7 @@ const hostConfig = {
|
|
|
513
628
|
// Microtasks
|
|
514
629
|
// (optional)
|
|
515
630
|
// -------------------
|
|
516
|
-
|
|
517
|
-
supportsMicrotasks: process.env.TARO_PLATFORM !== 'harmony',
|
|
631
|
+
supportsMicrotasks: true,
|
|
518
632
|
scheduleMicrotask: isUndefined(Promise)
|
|
519
633
|
? setTimeout
|
|
520
634
|
: (callback) => Promise.resolve(null)
|
|
@@ -539,6 +653,11 @@ const hostConfig = {
|
|
|
539
653
|
},
|
|
540
654
|
commitMount: noop,
|
|
541
655
|
commitUpdate(dom, updatePayload, _, oldProps, newProps) {
|
|
656
|
+
if (!updatePayload)
|
|
657
|
+
return;
|
|
658
|
+
// payload 只包含 children 的时候,不应该再继续触发后续的属性比较和更新的逻辑了
|
|
659
|
+
if (updatePayload.length === 2 && updatePayload.includes('children'))
|
|
660
|
+
return;
|
|
542
661
|
updatePropsByPayload(dom, oldProps, updatePayload);
|
|
543
662
|
updateFiberProps(dom, newProps);
|
|
544
663
|
},
|
|
@@ -814,8 +933,9 @@ var index = {
|
|
|
814
933
|
unstable_batchedUpdates,
|
|
815
934
|
unmountComponentAtNode,
|
|
816
935
|
findDOMNode,
|
|
817
|
-
createPortal
|
|
936
|
+
createPortal,
|
|
937
|
+
internalInstanceKey
|
|
818
938
|
};
|
|
819
939
|
|
|
820
|
-
export { createPortal, createRoot, index as default, findDOMNode, render, unmountComponentAtNode, unstable_batchedUpdates };
|
|
940
|
+
export { createPortal, createRoot, index as default, findDOMNode, internalInstanceKey, render, unmountComponentAtNode, unstable_batchedUpdates };
|
|
821
941
|
//# sourceMappingURL=react.esm.js.map
|