@tarojs/runtime 4.2.1-beta.1 → 4.2.1-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/bom/document.js +7 -2
- package/dist/bom/document.js.map +1 -1
- package/dist/dom/node.d.ts +1 -3
- package/dist/dom/node.js +0 -10
- package/dist/dom/node.js.map +1 -1
- package/dist/dom/root.d.ts +0 -2
- package/dist/dom/root.js +0 -4
- package/dist/dom/root.js.map +1 -1
- package/dist/dsl/common.d.ts +1 -1
- package/dist/dsl/common.js +9 -18
- package/dist/dsl/common.js.map +1 -1
- package/dist/index.cjs.d.ts +2 -9
- package/dist/index.cjs.js +16 -82
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime.esm.d.ts +2 -9
- package/dist/runtime.esm.js +17 -80
- package/dist/runtime.esm.js.map +1 -1
- package/package.json +2 -2
- package/dist/dom/nearest-ctx.d.ts +0 -9
- package/dist/dom/nearest-ctx.js +0 -49
- package/dist/dom/nearest-ctx.js.map +0 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1473,53 +1473,6 @@ class TaroEventTarget {
|
|
|
1473
1473
|
}
|
|
1474
1474
|
}
|
|
1475
1475
|
|
|
1476
|
-
const nearestCtxCache = new WeakMap();
|
|
1477
|
-
function isNearestCtxEnv() {
|
|
1478
|
-
return process.env.TARO_ENV === 'weapp' || process.env.TARO_ENV === 'jd';
|
|
1479
|
-
}
|
|
1480
|
-
function getNearestCtx(node) {
|
|
1481
|
-
if (!isNearestCtxEnv()) {
|
|
1482
|
-
return undefined;
|
|
1483
|
-
}
|
|
1484
|
-
const root = node._root;
|
|
1485
|
-
if (root == null) {
|
|
1486
|
-
return null;
|
|
1487
|
-
}
|
|
1488
|
-
const cached = nearestCtxCache.get(node);
|
|
1489
|
-
if (cached && cached.nearestCtxEpoch === root.nearestCtxEpoch) {
|
|
1490
|
-
return cached.value;
|
|
1491
|
-
}
|
|
1492
|
-
const value = resolveNearestCtxValue(node, root);
|
|
1493
|
-
nearestCtxCache.set(node, { value, nearestCtxEpoch: root.nearestCtxEpoch });
|
|
1494
|
-
return value;
|
|
1495
|
-
}
|
|
1496
|
-
function resolveNearestCtxValue(node, root) {
|
|
1497
|
-
var _a;
|
|
1498
|
-
if (node.nodeType === 1 /* NodeType.ELEMENT_NODE */) {
|
|
1499
|
-
const ctx = node.ctx;
|
|
1500
|
-
if (ctx != null)
|
|
1501
|
-
return ctx;
|
|
1502
|
-
}
|
|
1503
|
-
let current = node.parentNode;
|
|
1504
|
-
while (current) {
|
|
1505
|
-
if (current.nodeType === 1 /* NodeType.ELEMENT_NODE */) {
|
|
1506
|
-
const ctx = current.ctx;
|
|
1507
|
-
if (ctx != null)
|
|
1508
|
-
return ctx;
|
|
1509
|
-
}
|
|
1510
|
-
current = current.parentNode;
|
|
1511
|
-
}
|
|
1512
|
-
return (_a = root.ctx) !== null && _a !== void 0 ? _a : null;
|
|
1513
|
-
}
|
|
1514
|
-
function bumpNearestCtxEpochForRoot(root) {
|
|
1515
|
-
if (!isNearestCtxEnv() || root == null) {
|
|
1516
|
-
return;
|
|
1517
|
-
}
|
|
1518
|
-
if (typeof root.bumpNearestCtxEpoch === 'function') {
|
|
1519
|
-
root.bumpNearestCtxEpoch();
|
|
1520
|
-
}
|
|
1521
|
-
}
|
|
1522
|
-
|
|
1523
1476
|
const CHILDNODES = "cn" /* Shortcuts.Childnodes */;
|
|
1524
1477
|
const nodeId = incrementId();
|
|
1525
1478
|
class TaroNode extends TaroEventTarget {
|
|
@@ -1559,9 +1512,6 @@ class TaroNode extends TaroEventTarget {
|
|
|
1559
1512
|
var _a;
|
|
1560
1513
|
return ((_a = this.parentNode) === null || _a === void 0 ? void 0 : _a._root) || null;
|
|
1561
1514
|
}
|
|
1562
|
-
get _scope() {
|
|
1563
|
-
return getNearestCtx(this);
|
|
1564
|
-
}
|
|
1565
1515
|
findIndex(refChild) {
|
|
1566
1516
|
const index = this.childNodes.indexOf(refChild);
|
|
1567
1517
|
shared.ensure(index !== -1, 'The node to be replaced is not a child of this node.');
|
|
@@ -1707,9 +1657,6 @@ class TaroNode extends TaroEventTarget {
|
|
|
1707
1657
|
}
|
|
1708
1658
|
}
|
|
1709
1659
|
}
|
|
1710
|
-
if (this._root) {
|
|
1711
|
-
bumpNearestCtxEpochForRoot(this._root);
|
|
1712
|
-
}
|
|
1713
1660
|
MutationObserver$1.record({
|
|
1714
1661
|
type: "childList" /* MutationRecordType.CHILD_LIST */,
|
|
1715
1662
|
target: this,
|
|
@@ -1786,9 +1733,6 @@ class TaroNode extends TaroEventTarget {
|
|
|
1786
1733
|
if (this._root && doUpdate !== false) {
|
|
1787
1734
|
this.updateChildNodes();
|
|
1788
1735
|
}
|
|
1789
|
-
if (this._root) {
|
|
1790
|
-
bumpNearestCtxEpochForRoot(this._root);
|
|
1791
|
-
}
|
|
1792
1736
|
return child;
|
|
1793
1737
|
}
|
|
1794
1738
|
remove(options) {
|
|
@@ -3700,7 +3644,6 @@ class TaroRootElement extends TaroElement {
|
|
|
3700
3644
|
this.updateCallbacks = [];
|
|
3701
3645
|
this.pendingUpdate = false;
|
|
3702
3646
|
this.ctx = null;
|
|
3703
|
-
this.nearestCtxEpoch = 0;
|
|
3704
3647
|
this.nodeName = ROOT_STR;
|
|
3705
3648
|
this.tagName = ROOT_STR.toUpperCase();
|
|
3706
3649
|
}
|
|
@@ -3710,9 +3653,6 @@ class TaroRootElement extends TaroElement {
|
|
|
3710
3653
|
get _root() {
|
|
3711
3654
|
return this;
|
|
3712
3655
|
}
|
|
3713
|
-
bumpNearestCtxEpoch() {
|
|
3714
|
-
this.nearestCtxEpoch++;
|
|
3715
|
-
}
|
|
3716
3656
|
scheduleTask(fn) {
|
|
3717
3657
|
// 这里若使用微任务可略微提前setData的执行时机,但在部分场景下可能会出现连续setData两次,造成更大的性能问题
|
|
3718
3658
|
setTimeout(fn);
|
|
@@ -4084,8 +4024,13 @@ function createTTDomDocument() {
|
|
|
4084
4024
|
el.setAttribute = function (name, value) {
|
|
4085
4025
|
const result = originalSetAttribute(name, value);
|
|
4086
4026
|
// 处理 catchMove 属性
|
|
4087
|
-
if (name === 'catchMove'
|
|
4088
|
-
|
|
4027
|
+
if (name === 'catchMove') {
|
|
4028
|
+
if (value) {
|
|
4029
|
+
el.addEventListener('catchtouchmove', emptyFunction);
|
|
4030
|
+
}
|
|
4031
|
+
else {
|
|
4032
|
+
el.removeEventListener('catchtouchmove', emptyFunction);
|
|
4033
|
+
}
|
|
4089
4034
|
}
|
|
4090
4035
|
return result;
|
|
4091
4036
|
};
|
|
@@ -4276,7 +4221,6 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
4276
4221
|
pageElement.sync();
|
|
4277
4222
|
}
|
|
4278
4223
|
else {
|
|
4279
|
-
bumpNearestCtxEpochForRoot(pageElement);
|
|
4280
4224
|
pageElement.performUpdate(true, cb);
|
|
4281
4225
|
}
|
|
4282
4226
|
}
|
|
@@ -4305,7 +4249,6 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
4305
4249
|
unmounting = false;
|
|
4306
4250
|
instances.delete($taroPath);
|
|
4307
4251
|
if (pageElement) {
|
|
4308
|
-
bumpNearestCtxEpochForRoot(pageElement);
|
|
4309
4252
|
pageElement.ctx = null;
|
|
4310
4253
|
pageElement = null;
|
|
4311
4254
|
}
|
|
@@ -4468,42 +4411,36 @@ function createComponentConfig(component, componentName, data) {
|
|
|
4468
4411
|
});
|
|
4469
4412
|
return config;
|
|
4470
4413
|
}
|
|
4471
|
-
function createRecursiveComponentConfig(componentName
|
|
4414
|
+
function createRecursiveComponentConfig(componentName) {
|
|
4472
4415
|
const isCustomWrapper = componentName === CUSTOM_WRAPPER;
|
|
4473
4416
|
const [ATTACHED, DETACHED] = shared.hooks.call('getMiniLifecycleImpl').component;
|
|
4474
|
-
const lifeCycles = isCustomWrapper
|
|
4417
|
+
const lifeCycles = isCustomWrapper
|
|
4475
4418
|
? {
|
|
4476
4419
|
[ATTACHED]() {
|
|
4477
|
-
var _a, _b
|
|
4420
|
+
var _a, _b;
|
|
4478
4421
|
if (process.env.TARO_ENV === 'tt' && shared.isEnableTTDom()) {
|
|
4479
4422
|
return;
|
|
4480
4423
|
}
|
|
4481
|
-
const componentId = ((
|
|
4424
|
+
const componentId = ((_a = this.data.i) === null || _a === void 0 ? void 0 : _a.sid) || ((_b = this.props.i) === null || _b === void 0 ? void 0 : _b.sid);
|
|
4482
4425
|
if (shared.isString(componentId)) {
|
|
4483
|
-
|
|
4484
|
-
customWrapperCache.set(componentId, this);
|
|
4485
|
-
}
|
|
4426
|
+
customWrapperCache.set(componentId, this);
|
|
4486
4427
|
const el = env.document.getElementById(componentId);
|
|
4487
4428
|
if (el) {
|
|
4488
4429
|
el.ctx = this;
|
|
4489
|
-
bumpNearestCtxEpochForRoot(el._root);
|
|
4490
4430
|
}
|
|
4491
4431
|
}
|
|
4492
4432
|
},
|
|
4493
4433
|
[DETACHED]() {
|
|
4494
|
-
var _a, _b
|
|
4434
|
+
var _a, _b;
|
|
4495
4435
|
if (process.env.TARO_ENV === 'tt' && shared.isEnableTTDom()) {
|
|
4496
4436
|
return;
|
|
4497
4437
|
}
|
|
4498
|
-
const componentId = ((
|
|
4438
|
+
const componentId = ((_a = this.data.i) === null || _a === void 0 ? void 0 : _a.sid) || ((_b = this.props.i) === null || _b === void 0 ? void 0 : _b.sid);
|
|
4499
4439
|
if (shared.isString(componentId)) {
|
|
4500
|
-
|
|
4501
|
-
customWrapperCache.delete(componentId);
|
|
4502
|
-
}
|
|
4440
|
+
customWrapperCache.delete(componentId);
|
|
4503
4441
|
const el = env.document.getElementById(componentId);
|
|
4504
4442
|
if (el) {
|
|
4505
4443
|
el.ctx = null;
|
|
4506
|
-
bumpNearestCtxEpochForRoot(el._root);
|
|
4507
4444
|
}
|
|
4508
4445
|
}
|
|
4509
4446
|
}
|
|
@@ -4527,7 +4464,7 @@ function createRecursiveComponentConfig(componentName, forceCustomWrapper = fals
|
|
|
4527
4464
|
}
|
|
4528
4465
|
}, options: Object.assign(Object.assign({}, extraOptions), { virtualHost: !isCustomWrapper }), methods: {
|
|
4529
4466
|
eh: eventHandler
|
|
4530
|
-
} }, lifeCycles), { isCustomWrapper
|
|
4467
|
+
} }, lifeCycles), { isCustomWrapper });
|
|
4531
4468
|
}
|
|
4532
4469
|
|
|
4533
4470
|
const TIMEOUT = 100;
|
|
@@ -5413,7 +5350,6 @@ exports.URLSearchParams = URLSearchParams;
|
|
|
5413
5350
|
exports.VALUE = VALUE;
|
|
5414
5351
|
exports.VIEW = VIEW;
|
|
5415
5352
|
exports.addLeadingSlash = addLeadingSlash;
|
|
5416
|
-
exports.bumpNearestCtxEpochForRoot = bumpNearestCtxEpochForRoot;
|
|
5417
5353
|
exports.cancelAnimationFrame = _caf;
|
|
5418
5354
|
exports.convertNumber2PX = convertNumber2PX;
|
|
5419
5355
|
exports.createComponentConfig = createComponentConfig;
|
|
@@ -5434,7 +5370,6 @@ exports.getComputedStyle = taroGetComputedStyleProvider;
|
|
|
5434
5370
|
exports.getCurrentInstance = getCurrentInstance;
|
|
5435
5371
|
exports.getCurrentPage = getCurrentPage;
|
|
5436
5372
|
exports.getHomePage = getHomePage;
|
|
5437
|
-
exports.getNearestCtx = getNearestCtx;
|
|
5438
5373
|
exports.getOnHideEventKey = getOnHideEventKey;
|
|
5439
5374
|
exports.getOnReadyEventKey = getOnReadyEventKey;
|
|
5440
5375
|
exports.getOnShowEventKey = getOnShowEventKey;
|
|
@@ -5449,7 +5384,6 @@ exports.injectPageInstance = injectPageInstance;
|
|
|
5449
5384
|
exports.isComment = isComment;
|
|
5450
5385
|
exports.isElement = isElement;
|
|
5451
5386
|
exports.isHasExtractProp = isHasExtractProp;
|
|
5452
|
-
exports.isNearestCtxEnv = isNearestCtxEnv;
|
|
5453
5387
|
exports.isParentBound = isParentBound;
|
|
5454
5388
|
exports.isText = isText;
|
|
5455
5389
|
exports.location = taroLocationProvider;
|