@tarojs/runtime 3.6.8 → 3.6.9-alpha.2
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/runtime.esm.js +19 -9
- package/dist/runtime.esm.js.map +1 -1
- package/package.json +2 -2
package/dist/runtime.esm.js
CHANGED
|
@@ -4144,18 +4144,27 @@ function createRecursiveComponentConfig(componentName) {
|
|
|
4144
4144
|
} }, lifeCycles);
|
|
4145
4145
|
}
|
|
4146
4146
|
|
|
4147
|
+
const TIMEOUT = 100;
|
|
4147
4148
|
const nextTick = (cb, ctx) => {
|
|
4148
|
-
|
|
4149
|
+
const beginTime = Date.now();
|
|
4149
4150
|
const router = Current.router;
|
|
4150
4151
|
const timerFunc = () => {
|
|
4151
4152
|
setTimeout(function () {
|
|
4152
4153
|
ctx ? cb.call(ctx) : cb();
|
|
4153
4154
|
}, 1);
|
|
4154
4155
|
};
|
|
4155
|
-
if (router
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4156
|
+
if (router === null)
|
|
4157
|
+
return timerFunc();
|
|
4158
|
+
const path = router.$taroPath;
|
|
4159
|
+
/**
|
|
4160
|
+
* 三种情况
|
|
4161
|
+
* 1. 调用 nextTick 时,pendingUpdate 已经从 true 变为 false(即已更新完成),那么需要光等 100ms
|
|
4162
|
+
* 2. 调用 nextTick 时,pendingUpdate 为 true,那么刚好可以搭上便车
|
|
4163
|
+
* 3. 调用 nextTick 时,pendingUpdate 还是 false,框架仍未启动更新逻辑,这时最多轮询 100ms,等待 pendingUpdate 变为 true。
|
|
4164
|
+
*/
|
|
4165
|
+
function next() {
|
|
4166
|
+
var _a, _b, _c;
|
|
4167
|
+
const pageElement = env.document.getElementById(path);
|
|
4159
4168
|
if (pageElement === null || pageElement === void 0 ? void 0 : pageElement.pendingUpdate) {
|
|
4160
4169
|
if (isWebPlatform()) {
|
|
4161
4170
|
// eslint-disable-next-line dot-notation
|
|
@@ -4167,13 +4176,14 @@ const nextTick = (cb, ctx) => {
|
|
|
4167
4176
|
pageElement.enqueueUpdateCallback(cb, ctx);
|
|
4168
4177
|
}
|
|
4169
4178
|
}
|
|
4170
|
-
else {
|
|
4179
|
+
else if (Date.now() - beginTime > TIMEOUT) {
|
|
4171
4180
|
timerFunc();
|
|
4172
4181
|
}
|
|
4182
|
+
else {
|
|
4183
|
+
setTimeout(() => next(), 20);
|
|
4184
|
+
}
|
|
4173
4185
|
}
|
|
4174
|
-
|
|
4175
|
-
timerFunc();
|
|
4176
|
-
}
|
|
4186
|
+
next();
|
|
4177
4187
|
};
|
|
4178
4188
|
|
|
4179
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 };
|