@tarojs/runtime 4.2.1-beta.2 → 4.2.1
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 +5 -13
- package/dist/dsl/common.js.map +1 -1
- package/dist/index.cjs.d.ts +2 -9
- package/dist/index.cjs.js +12 -77
- 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 +13 -75
- 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
|
};
|
|
@@ -4304,7 +4249,6 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
4304
4249
|
unmounting = false;
|
|
4305
4250
|
instances.delete($taroPath);
|
|
4306
4251
|
if (pageElement) {
|
|
4307
|
-
bumpNearestCtxEpochForRoot(pageElement);
|
|
4308
4252
|
pageElement.ctx = null;
|
|
4309
4253
|
pageElement = null;
|
|
4310
4254
|
}
|
|
@@ -4467,10 +4411,10 @@ function createComponentConfig(component, componentName, data) {
|
|
|
4467
4411
|
});
|
|
4468
4412
|
return config;
|
|
4469
4413
|
}
|
|
4470
|
-
function createRecursiveComponentConfig(componentName
|
|
4414
|
+
function createRecursiveComponentConfig(componentName) {
|
|
4471
4415
|
const isCustomWrapper = componentName === CUSTOM_WRAPPER;
|
|
4472
4416
|
const [ATTACHED, DETACHED] = shared.hooks.call('getMiniLifecycleImpl').component;
|
|
4473
|
-
const lifeCycles = isCustomWrapper
|
|
4417
|
+
const lifeCycles = isCustomWrapper
|
|
4474
4418
|
? {
|
|
4475
4419
|
[ATTACHED]() {
|
|
4476
4420
|
var _a, _b;
|
|
@@ -4479,13 +4423,10 @@ function createRecursiveComponentConfig(componentName, forceCustomWrapper = fals
|
|
|
4479
4423
|
}
|
|
4480
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);
|
|
4481
4425
|
if (shared.isString(componentId)) {
|
|
4482
|
-
|
|
4483
|
-
customWrapperCache.set(componentId, this);
|
|
4484
|
-
}
|
|
4426
|
+
customWrapperCache.set(componentId, this);
|
|
4485
4427
|
const el = env.document.getElementById(componentId);
|
|
4486
4428
|
if (el) {
|
|
4487
4429
|
el.ctx = this;
|
|
4488
|
-
bumpNearestCtxEpochForRoot(el._root);
|
|
4489
4430
|
}
|
|
4490
4431
|
}
|
|
4491
4432
|
},
|
|
@@ -4496,13 +4437,10 @@ function createRecursiveComponentConfig(componentName, forceCustomWrapper = fals
|
|
|
4496
4437
|
}
|
|
4497
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);
|
|
4498
4439
|
if (shared.isString(componentId)) {
|
|
4499
|
-
|
|
4500
|
-
customWrapperCache.delete(componentId);
|
|
4501
|
-
}
|
|
4440
|
+
customWrapperCache.delete(componentId);
|
|
4502
4441
|
const el = env.document.getElementById(componentId);
|
|
4503
4442
|
if (el) {
|
|
4504
4443
|
el.ctx = null;
|
|
4505
|
-
bumpNearestCtxEpochForRoot(el._root);
|
|
4506
4444
|
}
|
|
4507
4445
|
}
|
|
4508
4446
|
}
|
|
@@ -4526,7 +4464,7 @@ function createRecursiveComponentConfig(componentName, forceCustomWrapper = fals
|
|
|
4526
4464
|
}
|
|
4527
4465
|
}, options: Object.assign(Object.assign({}, extraOptions), { virtualHost: !isCustomWrapper }), methods: {
|
|
4528
4466
|
eh: eventHandler
|
|
4529
|
-
} }, lifeCycles), { isCustomWrapper
|
|
4467
|
+
} }, lifeCycles), { isCustomWrapper });
|
|
4530
4468
|
}
|
|
4531
4469
|
|
|
4532
4470
|
const TIMEOUT = 100;
|
|
@@ -5412,7 +5350,6 @@ exports.URLSearchParams = URLSearchParams;
|
|
|
5412
5350
|
exports.VALUE = VALUE;
|
|
5413
5351
|
exports.VIEW = VIEW;
|
|
5414
5352
|
exports.addLeadingSlash = addLeadingSlash;
|
|
5415
|
-
exports.bumpNearestCtxEpochForRoot = bumpNearestCtxEpochForRoot;
|
|
5416
5353
|
exports.cancelAnimationFrame = _caf;
|
|
5417
5354
|
exports.convertNumber2PX = convertNumber2PX;
|
|
5418
5355
|
exports.createComponentConfig = createComponentConfig;
|
|
@@ -5433,7 +5370,6 @@ exports.getComputedStyle = taroGetComputedStyleProvider;
|
|
|
5433
5370
|
exports.getCurrentInstance = getCurrentInstance;
|
|
5434
5371
|
exports.getCurrentPage = getCurrentPage;
|
|
5435
5372
|
exports.getHomePage = getHomePage;
|
|
5436
|
-
exports.getNearestCtx = getNearestCtx;
|
|
5437
5373
|
exports.getOnHideEventKey = getOnHideEventKey;
|
|
5438
5374
|
exports.getOnReadyEventKey = getOnReadyEventKey;
|
|
5439
5375
|
exports.getOnShowEventKey = getOnShowEventKey;
|
|
@@ -5448,7 +5384,6 @@ exports.injectPageInstance = injectPageInstance;
|
|
|
5448
5384
|
exports.isComment = isComment;
|
|
5449
5385
|
exports.isElement = isElement;
|
|
5450
5386
|
exports.isHasExtractProp = isHasExtractProp;
|
|
5451
|
-
exports.isNearestCtxEnv = isNearestCtxEnv;
|
|
5452
5387
|
exports.isParentBound = isParentBound;
|
|
5453
5388
|
exports.isText = isText;
|
|
5454
5389
|
exports.location = taroLocationProvider;
|