@tarojs/runtime 3.7.0-canary.6 → 3.8.0-canary.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/LICENSE +14 -0
- package/dist/bom/URL.d.ts +54 -0
- package/dist/bom/URL.js +221 -0
- package/dist/bom/URL.js.map +1 -0
- package/dist/bom/URLSearchParams.d.ts +2 -0
- package/dist/bom/URLSearchParams.js +131 -0
- package/dist/bom/URLSearchParams.js.map +1 -0
- package/dist/bom/document.d.ts +3 -0
- package/dist/bom/document.js +39 -0
- package/dist/bom/document.js.map +1 -0
- package/dist/bom/getComputedStyle.d.ts +5 -0
- package/dist/bom/getComputedStyle.js +8 -0
- package/dist/bom/getComputedStyle.js.map +1 -0
- package/dist/bom/history.d.ts +32 -0
- package/dist/bom/history.js +121 -0
- package/dist/bom/history.js.map +1 -0
- package/dist/bom/location.d.ts +39 -0
- package/dist/bom/location.js +240 -0
- package/dist/bom/location.js.map +1 -0
- package/dist/bom/navigator.d.ts +2 -0
- package/dist/bom/navigator.js +24 -0
- package/dist/bom/navigator.js.map +1 -0
- package/dist/bom/raf.d.ts +4 -0
- package/dist/bom/raf.js +33 -0
- package/dist/bom/raf.js.map +1 -0
- package/dist/bom/window.d.ts +25 -0
- package/dist/bom/window.js +92 -0
- package/dist/bom/window.js.map +1 -0
- package/dist/constants/index.d.ts +60 -0
- package/dist/constants/index.js +63 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/current.d.ts +19 -0
- package/dist/current.js +9 -0
- package/dist/current.js.map +1 -0
- package/dist/dom/anchor-element.d.ts +14 -0
- package/dist/dom/anchor-element.js +54 -0
- package/dist/dom/anchor-element.js.map +1 -0
- package/dist/dom/class-list.d.ts +17 -0
- package/dist/dom/class-list.js +92 -0
- package/dist/dom/class-list.js.map +1 -0
- package/dist/dom/document.d.ts +25 -0
- package/dist/dom/document.js +80 -0
- package/dist/dom/document.js.map +1 -0
- package/dist/dom/element.d.ts +40 -0
- package/dist/dom/element.js +318 -0
- package/dist/dom/element.js.map +1 -0
- package/dist/dom/event-source.d.ts +7 -0
- package/dist/dom/event-source.js +17 -0
- package/dist/dom/event-source.js.map +1 -0
- package/dist/dom/event-target.d.ts +8 -0
- package/dist/dom/event-target.js +78 -0
- package/dist/dom/event-target.js.map +1 -0
- package/dist/dom/event.d.ts +24 -0
- package/dist/dom/event.js +152 -0
- package/dist/dom/event.js.map +1 -0
- package/dist/dom/form.d.ts +10 -0
- package/dist/dom/form.js +38 -0
- package/dist/dom/form.js.map +1 -0
- package/dist/dom/node.d.ts +107 -0
- package/dist/dom/node.js +292 -0
- package/dist/dom/node.js.map +1 -0
- package/dist/dom/root.d.ts +16 -0
- package/dist/dom/root.js +169 -0
- package/dist/dom/root.js.map +1 -0
- package/dist/dom/style.d.ts +15 -0
- package/dist/dom/style.js +168 -0
- package/dist/dom/style.js.map +1 -0
- package/dist/dom/style_properties.d.ts +3 -0
- package/dist/dom/style_properties.js +186 -0
- package/dist/dom/style_properties.js.map +1 -0
- package/dist/dom/svg.d.ts +4 -0
- package/dist/dom/svg.js +8 -0
- package/dist/dom/svg.js.map +1 -0
- package/dist/dom/text.d.ts +15 -0
- package/dist/dom/text.js +41 -0
- package/dist/dom/text.js.map +1 -0
- package/dist/dom/transfer.d.ts +8 -0
- package/dist/dom/transfer.js +15 -0
- package/dist/dom/transfer.js.map +1 -0
- package/dist/dom/tree.d.ts +4 -0
- package/dist/dom/tree.js +38 -0
- package/dist/dom/tree.js.map +1 -0
- package/dist/dom-external/element.d.ts +4 -0
- package/dist/dom-external/element.js +29 -0
- package/dist/dom-external/element.js.map +1 -0
- package/dist/dom-external/index.d.ts +1 -0
- package/dist/dom-external/index.js +38 -0
- package/dist/dom-external/index.js.map +1 -0
- package/dist/dom-external/inner-html/html.d.ts +3 -0
- package/dist/dom-external/inner-html/html.js +28 -0
- package/dist/dom-external/inner-html/html.js.map +1 -0
- package/dist/dom-external/inner-html/parser.d.ts +25 -0
- package/dist/dom-external/inner-html/parser.js +257 -0
- package/dist/dom-external/inner-html/parser.js.map +1 -0
- package/dist/dom-external/inner-html/scaner.d.ts +30 -0
- package/dist/dom-external/inner-html/scaner.js +304 -0
- package/dist/dom-external/inner-html/scaner.js.map +1 -0
- package/dist/dom-external/inner-html/style.d.ts +27 -0
- package/dist/dom-external/inner-html/style.js +235 -0
- package/dist/dom-external/inner-html/style.js.map +1 -0
- package/dist/dom-external/inner-html/tags.d.ts +14 -0
- package/dist/dom-external/inner-html/tags.js +41 -0
- package/dist/dom-external/inner-html/tags.js.map +1 -0
- package/dist/dom-external/inner-html/utils.d.ts +2 -0
- package/dist/dom-external/inner-html/utils.js +12 -0
- package/dist/dom-external/inner-html/utils.js.map +1 -0
- package/dist/dom-external/mutation-observer/implements.d.ts +71 -0
- package/dist/dom-external/mutation-observer/implements.js +108 -0
- package/dist/dom-external/mutation-observer/implements.js.map +1 -0
- package/dist/dom-external/mutation-observer/index.d.ts +12 -0
- package/dist/dom-external/mutation-observer/index.js +35 -0
- package/dist/dom-external/mutation-observer/index.js.map +1 -0
- package/dist/dom-external/node.d.ts +12 -0
- package/dist/dom-external/node.js +75 -0
- package/dist/dom-external/node.js.map +1 -0
- package/dist/dsl/common.d.ts +15 -0
- package/dist/dsl/common.js +337 -0
- package/dist/dsl/common.js.map +1 -0
- package/dist/emitter/emitter.d.ts +4 -0
- package/dist/emitter/emitter.js +7 -0
- package/dist/emitter/emitter.js.map +1 -0
- package/dist/env.d.ts +7 -0
- package/dist/env.js +9 -0
- package/dist/env.js.map +1 -0
- package/dist/hydrate.d.ts +11 -0
- package/dist/hydrate.js +91 -0
- package/dist/hydrate.js.map +1 -0
- package/dist/index-26658829.d.ts +23 -0
- package/dist/{runtime.cjs.d.ts → index.cjs.d.ts} +95 -88
- package/dist/{runtime.h5.js → index.cjs.js} +2276 -438
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/instance-0f017c6e.d.ts +95 -0
- package/dist/next-tick.d.ts +3 -0
- package/dist/next-tick.js +47 -0
- package/dist/next-tick.js.map +1 -0
- package/dist/node_types-9ac5b4dd.d.ts +11 -0
- package/dist/options-0f017c6e.d.ts +17 -0
- package/dist/options.d.ts +3 -0
- package/dist/options.js +7 -0
- package/dist/options.js.map +1 -0
- package/dist/perf.d.ts +7 -0
- package/dist/perf.js +28 -0
- package/dist/perf.js.map +1 -0
- package/dist/polyfill/array.d.ts +3 -0
- package/dist/polyfill/array.js +56 -0
- package/dist/polyfill/array.js.map +1 -0
- package/dist/polyfill/index.d.ts +2 -0
- package/dist/polyfill/index.js +34 -0
- package/dist/polyfill/index.js.map +1 -0
- package/dist/polyfill/intersection-observer.d.ts +2 -0
- package/dist/polyfill/intersection-observer.js +599 -0
- package/dist/polyfill/intersection-observer.js.map +1 -0
- package/dist/polyfill/object.d.ts +4 -0
- package/dist/polyfill/object.js +102 -0
- package/dist/polyfill/object.js.map +1 -0
- package/dist/record-32b054d8.d.ts +25 -0
- package/dist/runtime.esm.d.ts +95 -88
- package/dist/runtime.esm.js +1267 -427
- package/dist/runtime.esm.js.map +1 -1
- package/dist/utils/cache.d.ts +13 -0
- package/dist/utils/cache.js +27 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/index.d.ts +24 -0
- package/dist/utils/index.js +95 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/lodash.d.ts +2 -0
- package/dist/utils/lodash.js +22 -0
- package/dist/utils/lodash.js.map +1 -0
- package/dist/utils/router.d.ts +8 -0
- package/dist/utils/router.js +24 -0
- package/dist/utils/router.js.map +1 -0
- package/package.json +16 -11
- package/dist/runtime.cjs.js +0 -4614
- package/dist/runtime.h5.d.ts +0 -781
package/dist/runtime.esm.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { noop, isFunction, getComponentsAlias as getComponentsAlias$1, internalComponents,
|
|
1
|
+
import { noop, isFunction, getComponentsAlias as getComponentsAlias$1, internalComponents, EMPTY_OBJ, hooks, toCamelCase, isObject, warn, isArray, ensure, isNull, isUndefined, toDashed, isString, controlledComponent, Events, isNumber, EventChannel } from '@tarojs/shared';
|
|
2
2
|
export { Events, hooks } from '@tarojs/shared';
|
|
3
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet } from 'tslib';
|
|
3
4
|
|
|
4
5
|
const PROPERTY_THRESHOLD = 2046;
|
|
5
6
|
const TARO_RUNTIME = 'Taro runtime';
|
|
@@ -38,6 +39,7 @@ const KEY_CODE = 'keyCode';
|
|
|
38
39
|
const TOUCHMOVE = 'touchmove';
|
|
39
40
|
const DATE = 'Date';
|
|
40
41
|
const SET_TIMEOUT = 'setTimeout';
|
|
42
|
+
const COMPILE_MODE = 'compileMode';
|
|
41
43
|
const CATCHMOVE = 'catchMove';
|
|
42
44
|
const CATCH_VIEW = 'catch-view';
|
|
43
45
|
const COMMENT = 'comment';
|
|
@@ -167,7 +169,7 @@ function recordMutation(record) {
|
|
|
167
169
|
});
|
|
168
170
|
}
|
|
169
171
|
|
|
170
|
-
class MutationObserver {
|
|
172
|
+
let MutationObserver$1 = class MutationObserver {
|
|
171
173
|
constructor(callback) {
|
|
172
174
|
if (ENABLE_MUTATION_OBSERVER) {
|
|
173
175
|
this.core = new MutationObserverImpl(callback);
|
|
@@ -195,6 +197,26 @@ class MutationObserver {
|
|
|
195
197
|
static record(record) {
|
|
196
198
|
recordMutation(record);
|
|
197
199
|
}
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
function throttle(fn, threshold = 250, scope) {
|
|
203
|
+
let lastTime = 0;
|
|
204
|
+
let deferTimer;
|
|
205
|
+
return function (...args) {
|
|
206
|
+
const context = scope || this;
|
|
207
|
+
const now = Date.now();
|
|
208
|
+
if (now - lastTime > threshold) {
|
|
209
|
+
fn.apply(this, args);
|
|
210
|
+
lastTime = now;
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
clearTimeout(deferTimer);
|
|
214
|
+
deferTimer = setTimeout(() => {
|
|
215
|
+
lastTime = now;
|
|
216
|
+
fn.apply(context, args);
|
|
217
|
+
}, threshold);
|
|
218
|
+
}
|
|
219
|
+
};
|
|
198
220
|
}
|
|
199
221
|
|
|
200
222
|
const incrementId = () => {
|
|
@@ -392,10 +414,9 @@ class EventSource extends Map {
|
|
|
392
414
|
}
|
|
393
415
|
const eventSource = new EventSource();
|
|
394
416
|
|
|
395
|
-
const isWeb$1 = isWebPlatform();
|
|
396
417
|
const env = {
|
|
397
|
-
window:
|
|
398
|
-
document:
|
|
418
|
+
window: process.env.TARO_PLATFORM === 'web' ? window : EMPTY_OBJ,
|
|
419
|
+
document: process.env.TARO_PLATFORM === 'web' ? document : EMPTY_OBJ
|
|
399
420
|
};
|
|
400
421
|
|
|
401
422
|
let SPECIAL_NODES;
|
|
@@ -408,15 +429,12 @@ let componentsAlias;
|
|
|
408
429
|
*/
|
|
409
430
|
function hydrate(node) {
|
|
410
431
|
var _a;
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
if (!SPECIAL_NODES) {
|
|
416
|
-
// 初始化 SPECIAL_NODES
|
|
417
|
-
SPECIAL_NODES = hooks.call('getSpecialNodes');
|
|
418
|
-
}
|
|
432
|
+
// 初始化 componentsAlias
|
|
433
|
+
componentsAlias || (componentsAlias = getComponentsAlias());
|
|
434
|
+
// 初始化 SPECIAL_NODES
|
|
435
|
+
SPECIAL_NODES || (SPECIAL_NODES = hooks.call('getSpecialNodes'));
|
|
419
436
|
const nodeName = node.nodeName;
|
|
437
|
+
let compileModeName = null;
|
|
420
438
|
if (isText(node)) {
|
|
421
439
|
return {
|
|
422
440
|
sid: node.sid,
|
|
@@ -444,22 +462,22 @@ function hydrate(node) {
|
|
|
444
462
|
prop !== CLASS &&
|
|
445
463
|
prop !== STYLE &&
|
|
446
464
|
prop !== ID &&
|
|
447
|
-
propInCamelCase !== CATCHMOVE
|
|
465
|
+
propInCamelCase !== CATCHMOVE &&
|
|
466
|
+
propInCamelCase !== COMPILE_MODE) {
|
|
448
467
|
data[propInCamelCase] = props[prop];
|
|
449
468
|
}
|
|
450
|
-
if (
|
|
469
|
+
if (process.env.TARO_ENV !== 'swan' &&
|
|
470
|
+
nodeName === VIEW &&
|
|
471
|
+
propInCamelCase === CATCHMOVE &&
|
|
472
|
+
props[prop] !== false) {
|
|
451
473
|
data["nn" /* Shortcuts.NodeName */] = CATCH_VIEW;
|
|
452
474
|
}
|
|
475
|
+
if (propInCamelCase === COMPILE_MODE) {
|
|
476
|
+
compileModeName = props[prop];
|
|
477
|
+
}
|
|
453
478
|
}
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
childNodes = childNodes.filter(node => !isComment(node));
|
|
457
|
-
if (childNodes.length > 0) {
|
|
458
|
-
data["cn" /* Shortcuts.Childnodes */] = childNodes.map(hydrate);
|
|
459
|
-
}
|
|
460
|
-
else {
|
|
461
|
-
data["cn" /* Shortcuts.Childnodes */] = [];
|
|
462
|
-
}
|
|
479
|
+
// Children
|
|
480
|
+
data["cn" /* Shortcuts.Childnodes */] = node.childNodes.filter(node => !isComment(node)).map(hydrate);
|
|
463
481
|
if (node.className !== '') {
|
|
464
482
|
data["cl" /* Shortcuts.Class */] = node.className;
|
|
465
483
|
}
|
|
@@ -479,6 +497,9 @@ function hydrate(node) {
|
|
|
479
497
|
}
|
|
480
498
|
}
|
|
481
499
|
}
|
|
500
|
+
if (compileModeName !== null) {
|
|
501
|
+
data["nn" /* Shortcuts.NodeName */] = compileModeName;
|
|
502
|
+
}
|
|
482
503
|
const resData = hooks.call('transferHydrateData', data, node, componentAlias);
|
|
483
504
|
return resData || data;
|
|
484
505
|
}
|
|
@@ -656,7 +677,7 @@ class TaroNode extends TaroEventTarget {
|
|
|
656
677
|
this.updateChildNodes();
|
|
657
678
|
}
|
|
658
679
|
// @Todo: appendChild 会多触发一次
|
|
659
|
-
MutationObserver.record({
|
|
680
|
+
MutationObserver$1.record({
|
|
660
681
|
type: "childList" /* MutationRecordType.CHILD_LIST */,
|
|
661
682
|
target: this,
|
|
662
683
|
removedNodes,
|
|
@@ -741,7 +762,7 @@ class TaroNode extends TaroEventTarget {
|
|
|
741
762
|
}
|
|
742
763
|
}
|
|
743
764
|
}
|
|
744
|
-
MutationObserver.record({
|
|
765
|
+
MutationObserver$1.record({
|
|
745
766
|
type: "childList" /* MutationRecordType.CHILD_LIST */,
|
|
746
767
|
target: this,
|
|
747
768
|
addedNodes: [newChild],
|
|
@@ -797,7 +818,7 @@ class TaroNode extends TaroEventTarget {
|
|
|
797
818
|
if (cleanRef !== false && doUpdate !== false) {
|
|
798
819
|
// appendChild/replaceChild/insertBefore 不应该触发
|
|
799
820
|
// @Todo: 但其实如果 newChild 的父节点是另一颗子树的节点,应该是要触发的
|
|
800
|
-
MutationObserver.record({
|
|
821
|
+
MutationObserver$1.record({
|
|
801
822
|
type: "childList" /* MutationRecordType.CHILD_LIST */,
|
|
802
823
|
target: this,
|
|
803
824
|
removedNodes: [child],
|
|
@@ -1023,7 +1044,7 @@ combine('box', ['DecorationBreak', 'Shadow', 'Sizing', 'Snap'], true);
|
|
|
1023
1044
|
combine(WEBKIT, ['LineClamp', 'BoxOrient', 'TextFillColor', 'TextStroke', 'TextStrokeColor', 'TextStrokeWidth'], true);
|
|
1024
1045
|
|
|
1025
1046
|
function recordCss(obj) {
|
|
1026
|
-
MutationObserver.record({
|
|
1047
|
+
MutationObserver$1.record({
|
|
1027
1048
|
type: "attributes" /* MutationRecordType.ATTRIBUTES */,
|
|
1028
1049
|
target: obj._element,
|
|
1029
1050
|
attributeName: 'style',
|
|
@@ -1304,7 +1325,7 @@ class TaroElement extends TaroNode {
|
|
|
1304
1325
|
process.env.NODE_ENV !== 'production' && warn(isString(value) && value.length > PROPERTY_THRESHOLD, `元素 ${this.nodeName} 的 ${qualifiedName} 属性值数据量过大,可能会影响渲染性能。考虑降低图片转为 base64 的阈值或在 CSS 中使用 base64。`);
|
|
1305
1326
|
const isPureView = this.nodeName === VIEW && !isHasExtractProp(this) && !this.isAnyEventBinded();
|
|
1306
1327
|
if (qualifiedName !== STYLE) {
|
|
1307
|
-
MutationObserver.record({
|
|
1328
|
+
MutationObserver$1.record({
|
|
1308
1329
|
target: this,
|
|
1309
1330
|
type: "attributes" /* MutationRecordType.ATTRIBUTES */,
|
|
1310
1331
|
attributeName: qualifiedName,
|
|
@@ -1376,7 +1397,7 @@ class TaroElement extends TaroNode {
|
|
|
1376
1397
|
}
|
|
1377
1398
|
removeAttribute(qualifiedName) {
|
|
1378
1399
|
const isStaticView = this.nodeName === VIEW && isHasExtractProp(this) && !this.isAnyEventBinded();
|
|
1379
|
-
MutationObserver.record({
|
|
1400
|
+
MutationObserver$1.record({
|
|
1380
1401
|
target: this,
|
|
1381
1402
|
type: "attributes" /* MutationRecordType.ATTRIBUTES */,
|
|
1382
1403
|
attributeName: qualifiedName,
|
|
@@ -1469,7 +1490,10 @@ class TaroElement extends TaroNode {
|
|
|
1469
1490
|
event.defaultPrevented = true;
|
|
1470
1491
|
}
|
|
1471
1492
|
if (!isUndefined(result) && event.mpEvent) {
|
|
1472
|
-
|
|
1493
|
+
const res = hooks.call('modifyTaroEventReturn', this, event, result);
|
|
1494
|
+
if (res) {
|
|
1495
|
+
event.mpEvent[EVENT_CALLBACK_RESULT] = result;
|
|
1496
|
+
}
|
|
1473
1497
|
}
|
|
1474
1498
|
if (event._end && event._stop) {
|
|
1475
1499
|
break;
|
|
@@ -2080,15 +2104,30 @@ const specialMiniElements = {
|
|
|
2080
2104
|
img: 'image',
|
|
2081
2105
|
iframe: 'web-view'
|
|
2082
2106
|
};
|
|
2107
|
+
const specialElements = new Map([
|
|
2108
|
+
['a', {
|
|
2109
|
+
mapName(props) {
|
|
2110
|
+
if (props.as && isString(props.as))
|
|
2111
|
+
return props.as.toLowerCase();
|
|
2112
|
+
return !props.href || isString(props.href) && (/^javascript/.test(props.href)) ? 'view' : 'navigator';
|
|
2113
|
+
}
|
|
2114
|
+
}],
|
|
2115
|
+
]);
|
|
2116
|
+
const getSpecialElementMapping = (tag, expectsLowerCase = true) => {
|
|
2117
|
+
tag = expectsLowerCase ? tag.toLowerCase() : tag;
|
|
2118
|
+
return specialElements.get(tag);
|
|
2119
|
+
};
|
|
2083
2120
|
const internalCompsList = Object.keys(internalComponents)
|
|
2084
2121
|
.map(i => i.toLowerCase())
|
|
2085
2122
|
.join(',');
|
|
2086
2123
|
// https://developers.weixin.qq.com/miniprogram/dev/component
|
|
2087
2124
|
const isMiniElements = makeMap(internalCompsList, true);
|
|
2088
2125
|
// https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements
|
|
2089
|
-
const isInlineElements = makeMap('
|
|
2126
|
+
const isInlineElements = makeMap('i,abbr,iframe,select,acronym,slot,small,span,bdi,kbd,strong,big,map,sub,sup,br,mark,mark,meter,template,canvas,textarea,cite,object,time,code,output,u,data,picture,tt,datalist,var,dfn,del,q,em,s,embed,samp,b', true);
|
|
2090
2127
|
// https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements
|
|
2091
2128
|
const isBlockElements = makeMap('address,fieldset,li,article,figcaption,main,aside,figure,nav,blockquote,footer,ol,details,form,p,dialog,h1,h2,h3,h4,h5,h6,pre,dd,header,section,div,hgroup,table,dl,hr,ul,dt', true);
|
|
2129
|
+
// specialElements
|
|
2130
|
+
const isSpecialElements = makeMap('a', true);
|
|
2092
2131
|
|
|
2093
2132
|
const closingTagAncestorBreakers = {
|
|
2094
2133
|
li: ['ul', 'ol', 'menu'],
|
|
@@ -2117,7 +2156,21 @@ function hasTerminalParent(tagName, stack) {
|
|
|
2117
2156
|
}
|
|
2118
2157
|
return false;
|
|
2119
2158
|
}
|
|
2120
|
-
|
|
2159
|
+
/**
|
|
2160
|
+
* 将属性数组转换为属性对象
|
|
2161
|
+
* @param attributes 字符串数组,包含属性信息
|
|
2162
|
+
* @returns 属性对象,键为属性名,值为属性值或true
|
|
2163
|
+
*/
|
|
2164
|
+
function attributesArray2Props(attributes) {
|
|
2165
|
+
const props = {};
|
|
2166
|
+
for (let i = 0; i < attributes.length; i++) {
|
|
2167
|
+
const attr = attributes[i];
|
|
2168
|
+
const [key, value] = splitEqual(attr);
|
|
2169
|
+
props[key] = value == null ? true : unquote(value);
|
|
2170
|
+
}
|
|
2171
|
+
return props;
|
|
2172
|
+
}
|
|
2173
|
+
function getTagName(tag, attributes) {
|
|
2121
2174
|
if (options.html.renderHTMLTag) {
|
|
2122
2175
|
return tag;
|
|
2123
2176
|
}
|
|
@@ -2133,6 +2186,14 @@ function getTagName(tag) {
|
|
|
2133
2186
|
else if (isInlineElements(tag)) {
|
|
2134
2187
|
return 'text';
|
|
2135
2188
|
}
|
|
2189
|
+
else if (isSpecialElements(tag)) {
|
|
2190
|
+
// if it's special tag, the real tag is determined by the config mapping
|
|
2191
|
+
const mapping = getSpecialElementMapping(tag);
|
|
2192
|
+
const props = attributesArray2Props(attributes);
|
|
2193
|
+
if (mapping) {
|
|
2194
|
+
return mapping.mapName(props);
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2136
2197
|
return 'view';
|
|
2137
2198
|
}
|
|
2138
2199
|
function splitEqual(str) {
|
|
@@ -2166,7 +2227,26 @@ function format(children, document, styleOptions, parent) {
|
|
|
2166
2227
|
parent === null || parent === void 0 ? void 0 : parent.appendChild(text);
|
|
2167
2228
|
return text;
|
|
2168
2229
|
}
|
|
2169
|
-
|
|
2230
|
+
// img标签,把width和height写入style,删除原有的width、height和style属性
|
|
2231
|
+
if (child.tagName === 'img') {
|
|
2232
|
+
let styleText = '';
|
|
2233
|
+
const toBeRemovedIndexs = [];
|
|
2234
|
+
for (let i = 0; i < child.attributes.length; i++) {
|
|
2235
|
+
const attr = child.attributes[i];
|
|
2236
|
+
const [key, value] = splitEqual(attr);
|
|
2237
|
+
if (key === 'width' || key === 'height') {
|
|
2238
|
+
styleText += `${key}:${value};`;
|
|
2239
|
+
toBeRemovedIndexs.push(i);
|
|
2240
|
+
}
|
|
2241
|
+
else if (key === 'style') {
|
|
2242
|
+
styleText = `${styleText}${value};`;
|
|
2243
|
+
toBeRemovedIndexs.push(i);
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
child.attributes = child.attributes.filter((_, index) => !toBeRemovedIndexs.includes(index));
|
|
2247
|
+
child.attributes.push(`style=${styleText.replace(/['"]/g, '')}`);
|
|
2248
|
+
}
|
|
2249
|
+
const el = document.createElement(getTagName(child.tagName, child.attributes));
|
|
2170
2250
|
el.h5tagName = child.tagName;
|
|
2171
2251
|
parent === null || parent === void 0 ? void 0 : parent.appendChild(el);
|
|
2172
2252
|
if (!options.html.renderHTMLTag) {
|
|
@@ -2385,6 +2465,7 @@ function cloneNode(isDeep = false) {
|
|
|
2385
2465
|
}
|
|
2386
2466
|
for (const key in this) {
|
|
2387
2467
|
const value = this[key];
|
|
2468
|
+
// eslint-disable-next-line valid-typeof
|
|
2388
2469
|
if ([PROPS, DATASET].includes(key) && typeof value === OBJECT) {
|
|
2389
2470
|
newNode[key] = Object.assign({}, value);
|
|
2390
2471
|
}
|
|
@@ -2413,7 +2494,7 @@ function contains(node) {
|
|
|
2413
2494
|
return isContains;
|
|
2414
2495
|
}
|
|
2415
2496
|
|
|
2416
|
-
if (
|
|
2497
|
+
if (process.env.TARO_PLATFORM !== 'web') {
|
|
2417
2498
|
if (ENABLE_INNER_HTML) {
|
|
2418
2499
|
TaroNode.extend('innerHTML', {
|
|
2419
2500
|
set(html) {
|
|
@@ -2471,14 +2552,15 @@ class TaroEvent {
|
|
|
2471
2552
|
this.defaultPrevented = true;
|
|
2472
2553
|
}
|
|
2473
2554
|
get target() {
|
|
2474
|
-
var _a, _b, _c, _d;
|
|
2555
|
+
var _a, _b, _c, _d, _e;
|
|
2475
2556
|
const cacheTarget = this.cacheTarget;
|
|
2476
2557
|
if (!cacheTarget) {
|
|
2477
2558
|
const target = Object.create(((_a = this.mpEvent) === null || _a === void 0 ? void 0 : _a.target) || null);
|
|
2559
|
+
const currentEle = env.document.getElementById(((_b = target.dataset) === null || _b === void 0 ? void 0 : _b.sid) || target.id || null);
|
|
2478
2560
|
// Note:优先判断冒泡场景alipay的targetDataset的sid, 不然冒泡场景target属性吐出不对,其余拿取当前绑定id
|
|
2479
|
-
const element = env.document.getElementById(((
|
|
2480
|
-
target.dataset = element !== null ? element.dataset : EMPTY_OBJ;
|
|
2481
|
-
for (const key in (
|
|
2561
|
+
const element = env.document.getElementById(((_c = target.targetDataset) === null || _c === void 0 ? void 0 : _c.sid) || ((_d = target.dataset) === null || _d === void 0 ? void 0 : _d.sid) || target.id || null);
|
|
2562
|
+
target.dataset = Object.assign(Object.assign({}, (currentEle !== null ? currentEle.dataset : EMPTY_OBJ)), (element !== null ? element.dataset : EMPTY_OBJ));
|
|
2563
|
+
for (const key in (_e = this.mpEvent) === null || _e === void 0 ? void 0 : _e.detail) {
|
|
2482
2564
|
target[key] = this.mpEvent.detail[key];
|
|
2483
2565
|
}
|
|
2484
2566
|
this.cacheTarget = target;
|
|
@@ -2814,7 +2896,7 @@ class TaroText extends TaroNode {
|
|
|
2814
2896
|
this._value = value;
|
|
2815
2897
|
}
|
|
2816
2898
|
set textContent(text) {
|
|
2817
|
-
MutationObserver.record({
|
|
2899
|
+
MutationObserver$1.record({
|
|
2818
2900
|
target: this,
|
|
2819
2901
|
type: "characterData" /* MutationRecordType.CHARACTER_DATA */,
|
|
2820
2902
|
oldValue: this._value
|
|
@@ -2842,37 +2924,7 @@ class TaroText extends TaroNode {
|
|
|
2842
2924
|
}
|
|
2843
2925
|
}
|
|
2844
2926
|
|
|
2845
|
-
|
|
2846
|
-
Copyright (c) Microsoft Corporation.
|
|
2847
|
-
|
|
2848
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
2849
|
-
purpose with or without fee is hereby granted.
|
|
2850
|
-
|
|
2851
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
2852
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
2853
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
2854
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
2855
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
2856
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
2857
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
2858
|
-
***************************************************************************** */
|
|
2859
|
-
/* global Reflect, Promise */
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
2863
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
2864
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
2865
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
2866
|
-
}
|
|
2867
|
-
|
|
2868
|
-
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
2869
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
2870
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
2871
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
2872
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
2873
|
-
}
|
|
2874
|
-
|
|
2875
|
-
var _URLSearchParams_dict;
|
|
2927
|
+
var _dict, _a;
|
|
2876
2928
|
const findReg = /[!'()~]|%20|%00/g;
|
|
2877
2929
|
const plusReg = /\+/g;
|
|
2878
2930
|
const replaceCharMap = {
|
|
@@ -2903,93 +2955,102 @@ function decode(str) {
|
|
|
2903
2955
|
function encode(str) {
|
|
2904
2956
|
return encodeURIComponent(str).replace(findReg, replacer);
|
|
2905
2957
|
}
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
}
|
|
2915
|
-
for (let pairs = query.split('&'), i = 0, length = pairs.length; i < length; i++) {
|
|
2916
|
-
const value = pairs[i];
|
|
2917
|
-
const index = value.indexOf('=');
|
|
2918
|
-
if (index > -1) {
|
|
2919
|
-
appendTo(dict, decode(value.slice(0, index)), decode(value.slice(index + 1)));
|
|
2920
|
-
}
|
|
2921
|
-
else if (value.length) {
|
|
2922
|
-
appendTo(dict, decode(value), '');
|
|
2958
|
+
const URLSearchParams = process.env.TARO_PLATFORM === 'web' ? env.window.URLSearchParams : (_a = class {
|
|
2959
|
+
constructor(query) {
|
|
2960
|
+
_dict.set(this, Object.create(null));
|
|
2961
|
+
query !== null && query !== void 0 ? query : (query = '');
|
|
2962
|
+
const dict = __classPrivateFieldGet(this, _dict, "f");
|
|
2963
|
+
if (typeof query === 'string') {
|
|
2964
|
+
if (query.charAt(0) === '?') {
|
|
2965
|
+
query = query.slice(1);
|
|
2923
2966
|
}
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2967
|
+
for (let pairs = query.split('&'), i = 0, length = pairs.length; i < length; i++) {
|
|
2968
|
+
const value = pairs[i];
|
|
2969
|
+
const index = value.indexOf('=');
|
|
2970
|
+
// 针对不规范的 url 参数做容错处理,如:word=你%好
|
|
2971
|
+
try {
|
|
2972
|
+
if (index > -1) {
|
|
2973
|
+
appendTo(dict, decode(value.slice(0, index)), decode(value.slice(index + 1)));
|
|
2974
|
+
}
|
|
2975
|
+
else if (value.length) {
|
|
2976
|
+
appendTo(dict, decode(value), '');
|
|
2977
|
+
}
|
|
2978
|
+
}
|
|
2979
|
+
catch (err) {
|
|
2980
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2981
|
+
console.warn(`[Taro warn] URL 参数 ${value} decode 异常`);
|
|
2982
|
+
}
|
|
2983
|
+
}
|
|
2931
2984
|
}
|
|
2932
2985
|
}
|
|
2933
|
-
else if (query.forEach) {
|
|
2934
|
-
query.forEach(addEach, dict);
|
|
2935
|
-
}
|
|
2936
2986
|
else {
|
|
2937
|
-
|
|
2938
|
-
|
|
2987
|
+
if (isArray(query)) {
|
|
2988
|
+
for (let i = 0, length = query.length; i < length; i++) {
|
|
2989
|
+
const value = query[i];
|
|
2990
|
+
appendTo(dict, value[0], value[1]);
|
|
2991
|
+
}
|
|
2992
|
+
}
|
|
2993
|
+
else if (query.forEach) {
|
|
2994
|
+
query.forEach(addEach, dict);
|
|
2995
|
+
}
|
|
2996
|
+
else {
|
|
2997
|
+
for (const key in query) {
|
|
2998
|
+
appendTo(dict, key, query[key]);
|
|
2999
|
+
}
|
|
2939
3000
|
}
|
|
2940
3001
|
}
|
|
2941
3002
|
}
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
3003
|
+
append(name, value) {
|
|
3004
|
+
appendTo(__classPrivateFieldGet(this, _dict, "f"), name, value);
|
|
3005
|
+
}
|
|
3006
|
+
delete(name) {
|
|
3007
|
+
delete __classPrivateFieldGet(this, _dict, "f")[name];
|
|
3008
|
+
}
|
|
3009
|
+
get(name) {
|
|
3010
|
+
const dict = __classPrivateFieldGet(this, _dict, "f");
|
|
3011
|
+
return name in dict ? dict[name][0] : null;
|
|
3012
|
+
}
|
|
3013
|
+
getAll(name) {
|
|
3014
|
+
const dict = __classPrivateFieldGet(this, _dict, "f");
|
|
3015
|
+
return name in dict ? dict[name].slice(0) : [];
|
|
3016
|
+
}
|
|
3017
|
+
has(name) {
|
|
3018
|
+
return name in __classPrivateFieldGet(this, _dict, "f");
|
|
3019
|
+
}
|
|
3020
|
+
keys() {
|
|
3021
|
+
return Object.keys(__classPrivateFieldGet(this, _dict, "f"));
|
|
3022
|
+
}
|
|
3023
|
+
set(name, value) {
|
|
3024
|
+
__classPrivateFieldGet(this, _dict, "f")[name] = ['' + value];
|
|
3025
|
+
}
|
|
3026
|
+
forEach(callback, thisArg) {
|
|
3027
|
+
const dict = __classPrivateFieldGet(this, _dict, "f");
|
|
3028
|
+
Object.getOwnPropertyNames(dict).forEach(function (name) {
|
|
3029
|
+
dict[name].forEach(function (value) {
|
|
3030
|
+
callback.call(thisArg, value, name, this);
|
|
3031
|
+
}, this);
|
|
2971
3032
|
}, this);
|
|
2972
|
-
}
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
3033
|
+
}
|
|
3034
|
+
toJSON() {
|
|
3035
|
+
return {};
|
|
3036
|
+
}
|
|
3037
|
+
toString() {
|
|
3038
|
+
const dict = __classPrivateFieldGet(this, _dict, "f");
|
|
3039
|
+
const query = [];
|
|
3040
|
+
for (const key in dict) {
|
|
3041
|
+
const name = encode(key);
|
|
3042
|
+
for (let i = 0, value = dict[key]; i < value.length; i++) {
|
|
3043
|
+
query.push(name + '=' + encode(value[i]));
|
|
3044
|
+
}
|
|
2984
3045
|
}
|
|
3046
|
+
return query.join('&');
|
|
2985
3047
|
}
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
_URLSearchParams_dict = new WeakMap();
|
|
3048
|
+
},
|
|
3049
|
+
_dict = new WeakMap(),
|
|
3050
|
+
_a);
|
|
2990
3051
|
|
|
2991
|
-
var
|
|
2992
|
-
class
|
|
3052
|
+
var _TaroURL_hash, _TaroURL_hostname, _TaroURL_pathname, _TaroURL_port, _TaroURL_protocol, _TaroURL_search;
|
|
3053
|
+
class TaroURL {
|
|
2993
3054
|
static createObjectURL() {
|
|
2994
3055
|
throw new Error('Oops, not support URL.createObjectURL() in miniprogram.');
|
|
2995
3056
|
}
|
|
@@ -2998,29 +3059,29 @@ class URL {
|
|
|
2998
3059
|
}
|
|
2999
3060
|
constructor(url, base) {
|
|
3000
3061
|
/* private property */
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3062
|
+
_TaroURL_hash.set(this, '');
|
|
3063
|
+
_TaroURL_hostname.set(this, '');
|
|
3064
|
+
_TaroURL_pathname.set(this, '');
|
|
3065
|
+
_TaroURL_port.set(this, '');
|
|
3066
|
+
_TaroURL_protocol.set(this, '');
|
|
3067
|
+
_TaroURL_search.set(this, void 0);
|
|
3007
3068
|
if (!isString(url))
|
|
3008
3069
|
url = String(url);
|
|
3009
3070
|
const parseResult = parseUrlBase(url, base);
|
|
3010
3071
|
const { hash, hostname, pathname, port, protocol, search } = parseResult;
|
|
3011
|
-
__classPrivateFieldSet(this,
|
|
3012
|
-
__classPrivateFieldSet(this,
|
|
3013
|
-
__classPrivateFieldSet(this,
|
|
3014
|
-
__classPrivateFieldSet(this,
|
|
3015
|
-
__classPrivateFieldSet(this,
|
|
3016
|
-
__classPrivateFieldSet(this,
|
|
3072
|
+
__classPrivateFieldSet(this, _TaroURL_hash, hash, "f");
|
|
3073
|
+
__classPrivateFieldSet(this, _TaroURL_hostname, hostname, "f");
|
|
3074
|
+
__classPrivateFieldSet(this, _TaroURL_pathname, pathname || '/', "f");
|
|
3075
|
+
__classPrivateFieldSet(this, _TaroURL_port, port, "f");
|
|
3076
|
+
__classPrivateFieldSet(this, _TaroURL_protocol, protocol, "f");
|
|
3077
|
+
__classPrivateFieldSet(this, _TaroURL_search, new URLSearchParams(search), "f");
|
|
3017
3078
|
}
|
|
3018
3079
|
/* public property */
|
|
3019
3080
|
get protocol() {
|
|
3020
|
-
return __classPrivateFieldGet(this,
|
|
3081
|
+
return __classPrivateFieldGet(this, _TaroURL_protocol, "f");
|
|
3021
3082
|
}
|
|
3022
3083
|
set protocol(val) {
|
|
3023
|
-
isString(val) && (__classPrivateFieldSet(this,
|
|
3084
|
+
isString(val) && (__classPrivateFieldSet(this, _TaroURL_protocol, val.trim(), "f"));
|
|
3024
3085
|
}
|
|
3025
3086
|
get host() {
|
|
3026
3087
|
return this.hostname + (this.port ? ':' + this.port : '');
|
|
@@ -3034,19 +3095,19 @@ class URL {
|
|
|
3034
3095
|
}
|
|
3035
3096
|
}
|
|
3036
3097
|
get hostname() {
|
|
3037
|
-
return __classPrivateFieldGet(this,
|
|
3098
|
+
return __classPrivateFieldGet(this, _TaroURL_hostname, "f");
|
|
3038
3099
|
}
|
|
3039
3100
|
set hostname(val) {
|
|
3040
|
-
val && isString(val) && (__classPrivateFieldSet(this,
|
|
3101
|
+
val && isString(val) && (__classPrivateFieldSet(this, _TaroURL_hostname, val.trim(), "f"));
|
|
3041
3102
|
}
|
|
3042
3103
|
get port() {
|
|
3043
|
-
return __classPrivateFieldGet(this,
|
|
3104
|
+
return __classPrivateFieldGet(this, _TaroURL_port, "f");
|
|
3044
3105
|
}
|
|
3045
3106
|
set port(val) {
|
|
3046
|
-
isString(val) && (__classPrivateFieldSet(this,
|
|
3107
|
+
isString(val) && (__classPrivateFieldSet(this, _TaroURL_port, val.trim(), "f"));
|
|
3047
3108
|
}
|
|
3048
3109
|
get pathname() {
|
|
3049
|
-
return __classPrivateFieldGet(this,
|
|
3110
|
+
return __classPrivateFieldGet(this, _TaroURL_pathname, "f");
|
|
3050
3111
|
}
|
|
3051
3112
|
set pathname(val) {
|
|
3052
3113
|
if (isString(val)) {
|
|
@@ -3057,31 +3118,31 @@ class URL {
|
|
|
3057
3118
|
temp = temp.replace(HEAD_REG, '');
|
|
3058
3119
|
}
|
|
3059
3120
|
if (temp)
|
|
3060
|
-
__classPrivateFieldSet(this,
|
|
3121
|
+
__classPrivateFieldSet(this, _TaroURL_pathname, '/' + temp, "f");
|
|
3061
3122
|
else
|
|
3062
|
-
__classPrivateFieldSet(this,
|
|
3123
|
+
__classPrivateFieldSet(this, _TaroURL_pathname, '/', "f");
|
|
3063
3124
|
}
|
|
3064
3125
|
}
|
|
3065
3126
|
get search() {
|
|
3066
|
-
const val = __classPrivateFieldGet(this,
|
|
3127
|
+
const val = __classPrivateFieldGet(this, _TaroURL_search, "f").toString();
|
|
3067
3128
|
return (val.length === 0 || val.startsWith('?')) ? val : `?${val}`;
|
|
3068
3129
|
}
|
|
3069
3130
|
set search(val) {
|
|
3070
3131
|
if (isString(val)) {
|
|
3071
3132
|
val = val.trim();
|
|
3072
|
-
__classPrivateFieldSet(this,
|
|
3133
|
+
__classPrivateFieldSet(this, _TaroURL_search, new URLSearchParams(val), "f");
|
|
3073
3134
|
}
|
|
3074
3135
|
}
|
|
3075
3136
|
get hash() {
|
|
3076
|
-
return __classPrivateFieldGet(this,
|
|
3137
|
+
return __classPrivateFieldGet(this, _TaroURL_hash, "f");
|
|
3077
3138
|
}
|
|
3078
3139
|
set hash(val) {
|
|
3079
3140
|
if (isString(val)) {
|
|
3080
3141
|
val = val.trim();
|
|
3081
3142
|
if (val)
|
|
3082
|
-
__classPrivateFieldSet(this,
|
|
3143
|
+
__classPrivateFieldSet(this, _TaroURL_hash, val.startsWith('#') ? val : `#${val}`, "f");
|
|
3083
3144
|
else
|
|
3084
|
-
__classPrivateFieldSet(this,
|
|
3145
|
+
__classPrivateFieldSet(this, _TaroURL_hash, '', "f");
|
|
3085
3146
|
}
|
|
3086
3147
|
}
|
|
3087
3148
|
get href() {
|
|
@@ -3112,7 +3173,7 @@ class URL {
|
|
|
3112
3173
|
}
|
|
3113
3174
|
}
|
|
3114
3175
|
get searchParams() {
|
|
3115
|
-
return __classPrivateFieldGet(this,
|
|
3176
|
+
return __classPrivateFieldGet(this, _TaroURL_search, "f");
|
|
3116
3177
|
}
|
|
3117
3178
|
// public method
|
|
3118
3179
|
toString() {
|
|
@@ -3136,7 +3197,8 @@ class URL {
|
|
|
3136
3197
|
};
|
|
3137
3198
|
}
|
|
3138
3199
|
}
|
|
3139
|
-
|
|
3200
|
+
_TaroURL_hash = new WeakMap(), _TaroURL_hostname = new WeakMap(), _TaroURL_pathname = new WeakMap(), _TaroURL_port = new WeakMap(), _TaroURL_protocol = new WeakMap(), _TaroURL_search = new WeakMap();
|
|
3201
|
+
const URL = process.env.TARO_PLATFORM === 'web' ? env.window.URL : TaroURL;
|
|
3140
3202
|
function parseUrl(url = '') {
|
|
3141
3203
|
const result = {
|
|
3142
3204
|
href: '',
|
|
@@ -3327,49 +3389,42 @@ class TaroDocument extends TaroElement {
|
|
|
3327
3389
|
}
|
|
3328
3390
|
}
|
|
3329
3391
|
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
doc.head = head;
|
|
3361
|
-
doc.body = body;
|
|
3362
|
-
return doc;
|
|
3363
|
-
}
|
|
3364
|
-
document$1 = env.document = createDocument();
|
|
3365
|
-
}
|
|
3366
|
-
else {
|
|
3367
|
-
document$1 = env.document;
|
|
3392
|
+
function createDocument() {
|
|
3393
|
+
/**
|
|
3394
|
+
* <document>
|
|
3395
|
+
* <html>
|
|
3396
|
+
* <head></head>
|
|
3397
|
+
* <body>
|
|
3398
|
+
* <container>
|
|
3399
|
+
* <app id="app" />
|
|
3400
|
+
* </container>
|
|
3401
|
+
* </body>
|
|
3402
|
+
* </html>
|
|
3403
|
+
* </document>
|
|
3404
|
+
*/
|
|
3405
|
+
const doc = new TaroDocument();
|
|
3406
|
+
const documentCreateElement = doc.createElement.bind(doc);
|
|
3407
|
+
const html = documentCreateElement(HTML);
|
|
3408
|
+
const head = documentCreateElement(HEAD);
|
|
3409
|
+
const body = documentCreateElement(BODY);
|
|
3410
|
+
const app = documentCreateElement(APP);
|
|
3411
|
+
app.id = APP;
|
|
3412
|
+
const container = documentCreateElement(CONTAINER); // 多包一层主要为了兼容 vue
|
|
3413
|
+
doc.appendChild(html);
|
|
3414
|
+
html.appendChild(head);
|
|
3415
|
+
html.appendChild(body);
|
|
3416
|
+
body.appendChild(container);
|
|
3417
|
+
container.appendChild(app);
|
|
3418
|
+
doc.documentElement = html;
|
|
3419
|
+
doc.head = head;
|
|
3420
|
+
doc.body = body;
|
|
3421
|
+
return doc;
|
|
3368
3422
|
}
|
|
3423
|
+
const document$1 = process.env.TARO_PLATFORM === 'web' ? env.document : (env.document = createDocument());
|
|
3369
3424
|
|
|
3370
|
-
function
|
|
3425
|
+
const getComputedStyle = process.env.TARO_PLATFORM === 'web' ? env.window.getComputedStyle : function (element) {
|
|
3371
3426
|
return element.style;
|
|
3372
|
-
}
|
|
3427
|
+
};
|
|
3373
3428
|
|
|
3374
3429
|
const eventCenter = hooks.call('getEventCenter', Events);
|
|
3375
3430
|
|
|
@@ -3398,72 +3453,72 @@ class RuntimeCache {
|
|
|
3398
3453
|
}
|
|
3399
3454
|
}
|
|
3400
3455
|
|
|
3401
|
-
var
|
|
3456
|
+
var _TaroHistory_instances, _TaroHistory_location, _TaroHistory_stack, _TaroHistory_cur, _TaroHistory_window, _TaroHistory_reset;
|
|
3402
3457
|
const cache$1 = new RuntimeCache('history');
|
|
3403
|
-
class
|
|
3458
|
+
class TaroHistory extends Events {
|
|
3404
3459
|
constructor(location, options) {
|
|
3405
3460
|
super();
|
|
3406
|
-
|
|
3461
|
+
_TaroHistory_instances.add(this);
|
|
3407
3462
|
/* private property */
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
__classPrivateFieldSet(this,
|
|
3413
|
-
__classPrivateFieldSet(this,
|
|
3414
|
-
__classPrivateFieldGet(this,
|
|
3463
|
+
_TaroHistory_location.set(this, void 0);
|
|
3464
|
+
_TaroHistory_stack.set(this, []);
|
|
3465
|
+
_TaroHistory_cur.set(this, 0);
|
|
3466
|
+
_TaroHistory_window.set(this, void 0);
|
|
3467
|
+
__classPrivateFieldSet(this, _TaroHistory_window, options.window, "f");
|
|
3468
|
+
__classPrivateFieldSet(this, _TaroHistory_location, location, "f");
|
|
3469
|
+
__classPrivateFieldGet(this, _TaroHistory_location, "f").on('__record_history__', (href) => {
|
|
3415
3470
|
var _a;
|
|
3416
|
-
__classPrivateFieldSet(this,
|
|
3417
|
-
__classPrivateFieldSet(this,
|
|
3418
|
-
__classPrivateFieldGet(this,
|
|
3471
|
+
__classPrivateFieldSet(this, _TaroHistory_cur, (_a = __classPrivateFieldGet(this, _TaroHistory_cur, "f"), _a++, _a), "f");
|
|
3472
|
+
__classPrivateFieldSet(this, _TaroHistory_stack, __classPrivateFieldGet(this, _TaroHistory_stack, "f").slice(0, __classPrivateFieldGet(this, _TaroHistory_cur, "f")), "f");
|
|
3473
|
+
__classPrivateFieldGet(this, _TaroHistory_stack, "f").push({
|
|
3419
3474
|
state: null,
|
|
3420
3475
|
title: '',
|
|
3421
3476
|
url: href
|
|
3422
3477
|
});
|
|
3423
3478
|
}, null);
|
|
3424
|
-
__classPrivateFieldGet(this,
|
|
3425
|
-
__classPrivateFieldGet(this,
|
|
3479
|
+
__classPrivateFieldGet(this, _TaroHistory_location, "f").on('__reset_history__', (href) => {
|
|
3480
|
+
__classPrivateFieldGet(this, _TaroHistory_instances, "m", _TaroHistory_reset).call(this, href);
|
|
3426
3481
|
}, null);
|
|
3427
3482
|
// 切换上下文行为
|
|
3428
3483
|
this.on(CONTEXT_ACTIONS.INIT, () => {
|
|
3429
|
-
__classPrivateFieldGet(this,
|
|
3484
|
+
__classPrivateFieldGet(this, _TaroHistory_instances, "m", _TaroHistory_reset).call(this);
|
|
3430
3485
|
}, null);
|
|
3431
3486
|
this.on(CONTEXT_ACTIONS.RESTORE, (pageId) => {
|
|
3432
3487
|
cache$1.set(pageId, {
|
|
3433
|
-
location: __classPrivateFieldGet(this,
|
|
3434
|
-
stack: __classPrivateFieldGet(this,
|
|
3435
|
-
cur: __classPrivateFieldGet(this,
|
|
3488
|
+
location: __classPrivateFieldGet(this, _TaroHistory_location, "f"),
|
|
3489
|
+
stack: __classPrivateFieldGet(this, _TaroHistory_stack, "f").slice(),
|
|
3490
|
+
cur: __classPrivateFieldGet(this, _TaroHistory_cur, "f")
|
|
3436
3491
|
});
|
|
3437
3492
|
}, null);
|
|
3438
3493
|
this.on(CONTEXT_ACTIONS.RECOVER, (pageId) => {
|
|
3439
3494
|
if (cache$1.has(pageId)) {
|
|
3440
3495
|
const ctx = cache$1.get(pageId);
|
|
3441
|
-
__classPrivateFieldSet(this,
|
|
3442
|
-
__classPrivateFieldSet(this,
|
|
3443
|
-
__classPrivateFieldSet(this,
|
|
3496
|
+
__classPrivateFieldSet(this, _TaroHistory_location, ctx.location, "f");
|
|
3497
|
+
__classPrivateFieldSet(this, _TaroHistory_stack, ctx.stack, "f");
|
|
3498
|
+
__classPrivateFieldSet(this, _TaroHistory_cur, ctx.cur, "f");
|
|
3444
3499
|
}
|
|
3445
3500
|
}, null);
|
|
3446
3501
|
this.on(CONTEXT_ACTIONS.DESTORY, (pageId) => {
|
|
3447
3502
|
cache$1.delete(pageId);
|
|
3448
3503
|
}, null);
|
|
3449
|
-
__classPrivateFieldGet(this,
|
|
3504
|
+
__classPrivateFieldGet(this, _TaroHistory_instances, "m", _TaroHistory_reset).call(this);
|
|
3450
3505
|
}
|
|
3451
3506
|
/* public property */
|
|
3452
3507
|
get length() {
|
|
3453
|
-
return __classPrivateFieldGet(this,
|
|
3508
|
+
return __classPrivateFieldGet(this, _TaroHistory_stack, "f").length;
|
|
3454
3509
|
}
|
|
3455
3510
|
get state() {
|
|
3456
|
-
return __classPrivateFieldGet(this,
|
|
3511
|
+
return __classPrivateFieldGet(this, _TaroHistory_stack, "f")[__classPrivateFieldGet(this, _TaroHistory_cur, "f")].state;
|
|
3457
3512
|
}
|
|
3458
3513
|
/* public method */
|
|
3459
3514
|
go(delta) {
|
|
3460
3515
|
if (!isNumber(delta) || isNaN(delta))
|
|
3461
3516
|
return;
|
|
3462
|
-
let targetIdx = __classPrivateFieldGet(this,
|
|
3517
|
+
let targetIdx = __classPrivateFieldGet(this, _TaroHistory_cur, "f") + delta;
|
|
3463
3518
|
targetIdx = Math.min(Math.max(targetIdx, 0), this.length - 1);
|
|
3464
|
-
__classPrivateFieldSet(this,
|
|
3465
|
-
__classPrivateFieldGet(this,
|
|
3466
|
-
__classPrivateFieldGet(this,
|
|
3519
|
+
__classPrivateFieldSet(this, _TaroHistory_cur, targetIdx, "f");
|
|
3520
|
+
__classPrivateFieldGet(this, _TaroHistory_location, "f").trigger('__set_href_without_history__', __classPrivateFieldGet(this, _TaroHistory_stack, "f")[__classPrivateFieldGet(this, _TaroHistory_cur, "f")].url);
|
|
3521
|
+
__classPrivateFieldGet(this, _TaroHistory_window, "f").trigger('popstate', __classPrivateFieldGet(this, _TaroHistory_stack, "f")[__classPrivateFieldGet(this, _TaroHistory_cur, "f")]);
|
|
3467
3522
|
}
|
|
3468
3523
|
back() {
|
|
3469
3524
|
this.go(-1);
|
|
@@ -3474,40 +3529,41 @@ class History extends Events {
|
|
|
3474
3529
|
pushState(state, title, url) {
|
|
3475
3530
|
if (!url || !isString(url))
|
|
3476
3531
|
return;
|
|
3477
|
-
__classPrivateFieldSet(this,
|
|
3478
|
-
__classPrivateFieldGet(this,
|
|
3532
|
+
__classPrivateFieldSet(this, _TaroHistory_stack, __classPrivateFieldGet(this, _TaroHistory_stack, "f").slice(0, __classPrivateFieldGet(this, _TaroHistory_cur, "f") + 1), "f");
|
|
3533
|
+
__classPrivateFieldGet(this, _TaroHistory_stack, "f").push({
|
|
3479
3534
|
state,
|
|
3480
3535
|
title,
|
|
3481
3536
|
url
|
|
3482
3537
|
});
|
|
3483
|
-
__classPrivateFieldSet(this,
|
|
3484
|
-
__classPrivateFieldGet(this,
|
|
3538
|
+
__classPrivateFieldSet(this, _TaroHistory_cur, this.length - 1, "f");
|
|
3539
|
+
__classPrivateFieldGet(this, _TaroHistory_location, "f").trigger('__set_href_without_history__', url);
|
|
3485
3540
|
}
|
|
3486
3541
|
replaceState(state, title, url) {
|
|
3487
3542
|
if (!url || !isString(url))
|
|
3488
3543
|
return;
|
|
3489
|
-
__classPrivateFieldGet(this,
|
|
3544
|
+
__classPrivateFieldGet(this, _TaroHistory_stack, "f")[__classPrivateFieldGet(this, _TaroHistory_cur, "f")] = {
|
|
3490
3545
|
state,
|
|
3491
3546
|
title,
|
|
3492
3547
|
url
|
|
3493
3548
|
};
|
|
3494
|
-
__classPrivateFieldGet(this,
|
|
3549
|
+
__classPrivateFieldGet(this, _TaroHistory_location, "f").trigger('__set_href_without_history__', url);
|
|
3495
3550
|
}
|
|
3496
3551
|
// For debug
|
|
3497
3552
|
get cache() {
|
|
3498
3553
|
return cache$1;
|
|
3499
3554
|
}
|
|
3500
3555
|
}
|
|
3501
|
-
|
|
3502
|
-
__classPrivateFieldSet(this,
|
|
3556
|
+
_TaroHistory_location = new WeakMap(), _TaroHistory_stack = new WeakMap(), _TaroHistory_cur = new WeakMap(), _TaroHistory_window = new WeakMap(), _TaroHistory_instances = new WeakSet(), _TaroHistory_reset = function _TaroHistory_reset(href = '') {
|
|
3557
|
+
__classPrivateFieldSet(this, _TaroHistory_stack, [
|
|
3503
3558
|
{
|
|
3504
3559
|
state: null,
|
|
3505
3560
|
title: '',
|
|
3506
|
-
url: href || __classPrivateFieldGet(this,
|
|
3561
|
+
url: href || __classPrivateFieldGet(this, _TaroHistory_location, "f").href
|
|
3507
3562
|
}
|
|
3508
3563
|
], "f");
|
|
3509
|
-
__classPrivateFieldSet(this,
|
|
3564
|
+
__classPrivateFieldSet(this, _TaroHistory_cur, 0, "f");
|
|
3510
3565
|
};
|
|
3566
|
+
const History = process.env.TARO_PLATFORM === 'web' ? env.window.History : TaroHistory;
|
|
3511
3567
|
|
|
3512
3568
|
const Current = {
|
|
3513
3569
|
app: null,
|
|
@@ -3516,31 +3572,31 @@ const Current = {
|
|
|
3516
3572
|
};
|
|
3517
3573
|
const getCurrentInstance = () => Current;
|
|
3518
3574
|
|
|
3519
|
-
var
|
|
3575
|
+
var _TaroLocation_instances, _TaroLocation_url, _TaroLocation_noCheckUrl, _TaroLocation_window, _TaroLocation_reset, _TaroLocation_getPreValue, _TaroLocation_rollBack, _TaroLocation_recordHistory, _TaroLocation_checkUrlChange;
|
|
3520
3576
|
const INIT_URL = 'https://taro.com';
|
|
3521
3577
|
const cache = new RuntimeCache('location');
|
|
3522
|
-
class
|
|
3578
|
+
class TaroLocation extends Events {
|
|
3523
3579
|
constructor(options) {
|
|
3524
3580
|
super();
|
|
3525
|
-
|
|
3581
|
+
_TaroLocation_instances.add(this);
|
|
3526
3582
|
/* private property */
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
__classPrivateFieldSet(this,
|
|
3531
|
-
__classPrivateFieldGet(this,
|
|
3583
|
+
_TaroLocation_url.set(this, new URL(INIT_URL));
|
|
3584
|
+
_TaroLocation_noCheckUrl.set(this, false);
|
|
3585
|
+
_TaroLocation_window.set(this, void 0);
|
|
3586
|
+
__classPrivateFieldSet(this, _TaroLocation_window, options.window, "f");
|
|
3587
|
+
__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_reset).call(this);
|
|
3532
3588
|
this.on('__set_href_without_history__', (href) => {
|
|
3533
|
-
__classPrivateFieldSet(this,
|
|
3534
|
-
const lastHash = __classPrivateFieldGet(this,
|
|
3535
|
-
__classPrivateFieldGet(this,
|
|
3536
|
-
if (lastHash !== __classPrivateFieldGet(this,
|
|
3537
|
-
__classPrivateFieldGet(this,
|
|
3589
|
+
__classPrivateFieldSet(this, _TaroLocation_noCheckUrl, true, "f");
|
|
3590
|
+
const lastHash = __classPrivateFieldGet(this, _TaroLocation_url, "f").hash;
|
|
3591
|
+
__classPrivateFieldGet(this, _TaroLocation_url, "f").href = generateFullUrl(href);
|
|
3592
|
+
if (lastHash !== __classPrivateFieldGet(this, _TaroLocation_url, "f").hash) {
|
|
3593
|
+
__classPrivateFieldGet(this, _TaroLocation_window, "f").trigger('hashchange');
|
|
3538
3594
|
}
|
|
3539
|
-
__classPrivateFieldSet(this,
|
|
3595
|
+
__classPrivateFieldSet(this, _TaroLocation_noCheckUrl, false, "f");
|
|
3540
3596
|
}, null);
|
|
3541
3597
|
// 切换上下文行为
|
|
3542
3598
|
this.on(CONTEXT_ACTIONS.INIT, () => {
|
|
3543
|
-
__classPrivateFieldGet(this,
|
|
3599
|
+
__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_reset).call(this);
|
|
3544
3600
|
}, null);
|
|
3545
3601
|
this.on(CONTEXT_ACTIONS.RESTORE, (pageId) => {
|
|
3546
3602
|
cache.set(pageId, {
|
|
@@ -3551,9 +3607,9 @@ class Location extends Events {
|
|
|
3551
3607
|
// 数据恢复时,不需要执行跳转
|
|
3552
3608
|
if (cache.has(pageId)) {
|
|
3553
3609
|
const ctx = cache.get(pageId);
|
|
3554
|
-
__classPrivateFieldSet(this,
|
|
3555
|
-
__classPrivateFieldGet(this,
|
|
3556
|
-
__classPrivateFieldSet(this,
|
|
3610
|
+
__classPrivateFieldSet(this, _TaroLocation_noCheckUrl, true, "f");
|
|
3611
|
+
__classPrivateFieldGet(this, _TaroLocation_url, "f").href = ctx.lastHref;
|
|
3612
|
+
__classPrivateFieldSet(this, _TaroLocation_noCheckUrl, false, "f");
|
|
3557
3613
|
}
|
|
3558
3614
|
}, null);
|
|
3559
3615
|
this.on(CONTEXT_ACTIONS.DESTORY, (pageId) => {
|
|
@@ -3562,81 +3618,81 @@ class Location extends Events {
|
|
|
3562
3618
|
}
|
|
3563
3619
|
/* public property */
|
|
3564
3620
|
get protocol() {
|
|
3565
|
-
return __classPrivateFieldGet(this,
|
|
3621
|
+
return __classPrivateFieldGet(this, _TaroLocation_url, "f").protocol;
|
|
3566
3622
|
}
|
|
3567
3623
|
set protocol(val) {
|
|
3568
3624
|
const REG = /^(http|https):$/i;
|
|
3569
3625
|
if (!val || !isString(val) || !REG.test(val.trim()))
|
|
3570
3626
|
return;
|
|
3571
3627
|
val = val.trim();
|
|
3572
|
-
const preValue = __classPrivateFieldGet(this,
|
|
3573
|
-
__classPrivateFieldGet(this,
|
|
3574
|
-
if (__classPrivateFieldGet(this,
|
|
3575
|
-
__classPrivateFieldGet(this,
|
|
3628
|
+
const preValue = __classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_getPreValue).call(this);
|
|
3629
|
+
__classPrivateFieldGet(this, _TaroLocation_url, "f").protocol = val;
|
|
3630
|
+
if (__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_checkUrlChange).call(this, preValue))
|
|
3631
|
+
__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_recordHistory).call(this);
|
|
3576
3632
|
}
|
|
3577
3633
|
get host() {
|
|
3578
|
-
return __classPrivateFieldGet(this,
|
|
3634
|
+
return __classPrivateFieldGet(this, _TaroLocation_url, "f").host;
|
|
3579
3635
|
}
|
|
3580
3636
|
set host(val) {
|
|
3581
3637
|
if (!val || !isString(val))
|
|
3582
3638
|
return;
|
|
3583
3639
|
val = val.trim();
|
|
3584
|
-
const preValue = __classPrivateFieldGet(this,
|
|
3585
|
-
__classPrivateFieldGet(this,
|
|
3586
|
-
if (__classPrivateFieldGet(this,
|
|
3587
|
-
__classPrivateFieldGet(this,
|
|
3640
|
+
const preValue = __classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_getPreValue).call(this);
|
|
3641
|
+
__classPrivateFieldGet(this, _TaroLocation_url, "f").host = val;
|
|
3642
|
+
if (__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_checkUrlChange).call(this, preValue))
|
|
3643
|
+
__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_recordHistory).call(this);
|
|
3588
3644
|
}
|
|
3589
3645
|
get hostname() {
|
|
3590
|
-
return __classPrivateFieldGet(this,
|
|
3646
|
+
return __classPrivateFieldGet(this, _TaroLocation_url, "f").hostname;
|
|
3591
3647
|
}
|
|
3592
3648
|
set hostname(val) {
|
|
3593
3649
|
if (!val || !isString(val))
|
|
3594
3650
|
return;
|
|
3595
3651
|
val = val.trim();
|
|
3596
|
-
const preValue = __classPrivateFieldGet(this,
|
|
3597
|
-
__classPrivateFieldGet(this,
|
|
3598
|
-
if (__classPrivateFieldGet(this,
|
|
3599
|
-
__classPrivateFieldGet(this,
|
|
3652
|
+
const preValue = __classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_getPreValue).call(this);
|
|
3653
|
+
__classPrivateFieldGet(this, _TaroLocation_url, "f").hostname = val;
|
|
3654
|
+
if (__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_checkUrlChange).call(this, preValue))
|
|
3655
|
+
__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_recordHistory).call(this);
|
|
3600
3656
|
}
|
|
3601
3657
|
get port() {
|
|
3602
|
-
return __classPrivateFieldGet(this,
|
|
3658
|
+
return __classPrivateFieldGet(this, _TaroLocation_url, "f").port;
|
|
3603
3659
|
}
|
|
3604
3660
|
set port(val) {
|
|
3605
3661
|
const xVal = Number((val = val.trim()));
|
|
3606
3662
|
if (!isNumber(xVal) || xVal <= 0)
|
|
3607
3663
|
return;
|
|
3608
|
-
const preValue = __classPrivateFieldGet(this,
|
|
3609
|
-
__classPrivateFieldGet(this,
|
|
3610
|
-
if (__classPrivateFieldGet(this,
|
|
3611
|
-
__classPrivateFieldGet(this,
|
|
3664
|
+
const preValue = __classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_getPreValue).call(this);
|
|
3665
|
+
__classPrivateFieldGet(this, _TaroLocation_url, "f").port = val;
|
|
3666
|
+
if (__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_checkUrlChange).call(this, preValue))
|
|
3667
|
+
__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_recordHistory).call(this);
|
|
3612
3668
|
}
|
|
3613
3669
|
get pathname() {
|
|
3614
|
-
return __classPrivateFieldGet(this,
|
|
3670
|
+
return __classPrivateFieldGet(this, _TaroLocation_url, "f").pathname;
|
|
3615
3671
|
}
|
|
3616
3672
|
set pathname(val) {
|
|
3617
3673
|
if (!val || !isString(val))
|
|
3618
3674
|
return;
|
|
3619
3675
|
val = val.trim();
|
|
3620
|
-
const preValue = __classPrivateFieldGet(this,
|
|
3621
|
-
__classPrivateFieldGet(this,
|
|
3622
|
-
if (__classPrivateFieldGet(this,
|
|
3623
|
-
__classPrivateFieldGet(this,
|
|
3676
|
+
const preValue = __classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_getPreValue).call(this);
|
|
3677
|
+
__classPrivateFieldGet(this, _TaroLocation_url, "f").pathname = val;
|
|
3678
|
+
if (__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_checkUrlChange).call(this, preValue))
|
|
3679
|
+
__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_recordHistory).call(this);
|
|
3624
3680
|
}
|
|
3625
3681
|
get search() {
|
|
3626
|
-
return __classPrivateFieldGet(this,
|
|
3682
|
+
return __classPrivateFieldGet(this, _TaroLocation_url, "f").search;
|
|
3627
3683
|
}
|
|
3628
3684
|
set search(val) {
|
|
3629
3685
|
if (!val || !isString(val))
|
|
3630
3686
|
return;
|
|
3631
3687
|
val = val.trim();
|
|
3632
3688
|
val = val.startsWith('?') ? val : `?${val}`;
|
|
3633
|
-
const preValue = __classPrivateFieldGet(this,
|
|
3634
|
-
__classPrivateFieldGet(this,
|
|
3635
|
-
if (__classPrivateFieldGet(this,
|
|
3636
|
-
__classPrivateFieldGet(this,
|
|
3689
|
+
const preValue = __classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_getPreValue).call(this);
|
|
3690
|
+
__classPrivateFieldGet(this, _TaroLocation_url, "f").search = val;
|
|
3691
|
+
if (__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_checkUrlChange).call(this, preValue))
|
|
3692
|
+
__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_recordHistory).call(this);
|
|
3637
3693
|
}
|
|
3638
3694
|
get hash() {
|
|
3639
|
-
return __classPrivateFieldGet(this,
|
|
3695
|
+
return __classPrivateFieldGet(this, _TaroLocation_url, "f").hash;
|
|
3640
3696
|
}
|
|
3641
3697
|
// 小程序的navigateTo存在截断hash字符串的问题
|
|
3642
3698
|
set hash(val) {
|
|
@@ -3644,34 +3700,34 @@ class Location extends Events {
|
|
|
3644
3700
|
return;
|
|
3645
3701
|
val = val.trim();
|
|
3646
3702
|
val = val.startsWith('#') ? val : `#${val}`;
|
|
3647
|
-
const preValue = __classPrivateFieldGet(this,
|
|
3648
|
-
__classPrivateFieldGet(this,
|
|
3649
|
-
if (__classPrivateFieldGet(this,
|
|
3650
|
-
__classPrivateFieldGet(this,
|
|
3703
|
+
const preValue = __classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_getPreValue).call(this);
|
|
3704
|
+
__classPrivateFieldGet(this, _TaroLocation_url, "f").hash = val;
|
|
3705
|
+
if (__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_checkUrlChange).call(this, preValue))
|
|
3706
|
+
__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_recordHistory).call(this);
|
|
3651
3707
|
}
|
|
3652
3708
|
get href() {
|
|
3653
|
-
return __classPrivateFieldGet(this,
|
|
3709
|
+
return __classPrivateFieldGet(this, _TaroLocation_url, "f").href;
|
|
3654
3710
|
}
|
|
3655
3711
|
set href(val) {
|
|
3656
3712
|
const REG = /^(http:|https:)?\/\/.+/;
|
|
3657
3713
|
if (!val || !isString(val) || !REG.test((val = val.trim())))
|
|
3658
3714
|
return;
|
|
3659
|
-
const preValue = __classPrivateFieldGet(this,
|
|
3660
|
-
__classPrivateFieldGet(this,
|
|
3661
|
-
if (__classPrivateFieldGet(this,
|
|
3662
|
-
__classPrivateFieldGet(this,
|
|
3715
|
+
const preValue = __classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_getPreValue).call(this);
|
|
3716
|
+
__classPrivateFieldGet(this, _TaroLocation_url, "f").href = val;
|
|
3717
|
+
if (__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_checkUrlChange).call(this, preValue))
|
|
3718
|
+
__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_recordHistory).call(this);
|
|
3663
3719
|
}
|
|
3664
3720
|
get origin() {
|
|
3665
|
-
return __classPrivateFieldGet(this,
|
|
3721
|
+
return __classPrivateFieldGet(this, _TaroLocation_url, "f").origin;
|
|
3666
3722
|
}
|
|
3667
3723
|
set origin(val) {
|
|
3668
3724
|
const REG = /^(http:|https:)?\/\/.+/;
|
|
3669
3725
|
if (!val || !isString(val) || !REG.test((val = val.trim())))
|
|
3670
3726
|
return;
|
|
3671
|
-
const preValue = __classPrivateFieldGet(this,
|
|
3672
|
-
__classPrivateFieldGet(this,
|
|
3673
|
-
if (__classPrivateFieldGet(this,
|
|
3674
|
-
__classPrivateFieldGet(this,
|
|
3727
|
+
const preValue = __classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_getPreValue).call(this);
|
|
3728
|
+
__classPrivateFieldGet(this, _TaroLocation_url, "f").origin = val;
|
|
3729
|
+
if (__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_checkUrlChange).call(this, preValue))
|
|
3730
|
+
__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_recordHistory).call(this);
|
|
3675
3731
|
}
|
|
3676
3732
|
/* public method */
|
|
3677
3733
|
assign() {
|
|
@@ -3691,7 +3747,7 @@ class Location extends Events {
|
|
|
3691
3747
|
return cache;
|
|
3692
3748
|
}
|
|
3693
3749
|
}
|
|
3694
|
-
|
|
3750
|
+
_TaroLocation_url = new WeakMap(), _TaroLocation_noCheckUrl = new WeakMap(), _TaroLocation_window = new WeakMap(), _TaroLocation_instances = new WeakSet(), _TaroLocation_reset = function _TaroLocation_reset() {
|
|
3695
3751
|
const Current = getCurrentInstance();
|
|
3696
3752
|
const router = Current.router;
|
|
3697
3753
|
if (router) {
|
|
@@ -3701,23 +3757,23 @@ _Location_url = new WeakMap(), _Location_noCheckUrl = new WeakMap(), _Location_w
|
|
|
3701
3757
|
});
|
|
3702
3758
|
const searchStr = searchArr.length > 0 ? '?' + searchArr.join('&') : '';
|
|
3703
3759
|
const url = `${INIT_URL}${path.startsWith('/') ? path : '/' + path}${searchStr}`;
|
|
3704
|
-
__classPrivateFieldSet(this,
|
|
3760
|
+
__classPrivateFieldSet(this, _TaroLocation_url, new URL(url), "f");
|
|
3705
3761
|
this.trigger('__reset_history__', this.href);
|
|
3706
3762
|
}
|
|
3707
|
-
},
|
|
3708
|
-
return __classPrivateFieldGet(this,
|
|
3709
|
-
},
|
|
3710
|
-
__classPrivateFieldGet(this,
|
|
3711
|
-
},
|
|
3763
|
+
}, _TaroLocation_getPreValue = function _TaroLocation_getPreValue() {
|
|
3764
|
+
return __classPrivateFieldGet(this, _TaroLocation_url, "f")._toRaw();
|
|
3765
|
+
}, _TaroLocation_rollBack = function _TaroLocation_rollBack(href) {
|
|
3766
|
+
__classPrivateFieldGet(this, _TaroLocation_url, "f").href = href;
|
|
3767
|
+
}, _TaroLocation_recordHistory = function _TaroLocation_recordHistory() {
|
|
3712
3768
|
this.trigger('__record_history__', this.href);
|
|
3713
|
-
},
|
|
3714
|
-
if (__classPrivateFieldGet(this,
|
|
3769
|
+
}, _TaroLocation_checkUrlChange = function _TaroLocation_checkUrlChange(preValue) {
|
|
3770
|
+
if (__classPrivateFieldGet(this, _TaroLocation_noCheckUrl, "f")) {
|
|
3715
3771
|
return false;
|
|
3716
3772
|
}
|
|
3717
|
-
const { protocol, hostname, port, pathname, search, hash } = __classPrivateFieldGet(this,
|
|
3773
|
+
const { protocol, hostname, port, pathname, search, hash } = __classPrivateFieldGet(this, _TaroLocation_url, "f")._toRaw();
|
|
3718
3774
|
// 跨域三要素不允许修改
|
|
3719
3775
|
if (protocol !== preValue.protocol || hostname !== preValue.hostname || port !== preValue.port) {
|
|
3720
|
-
__classPrivateFieldGet(this,
|
|
3776
|
+
__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_rollBack).call(this, preValue.href);
|
|
3721
3777
|
return false;
|
|
3722
3778
|
}
|
|
3723
3779
|
// pathname
|
|
@@ -3730,12 +3786,13 @@ _Location_url = new WeakMap(), _Location_noCheckUrl = new WeakMap(), _Location_w
|
|
|
3730
3786
|
}
|
|
3731
3787
|
// hashchange
|
|
3732
3788
|
if (hash !== preValue.hash) {
|
|
3733
|
-
__classPrivateFieldGet(this,
|
|
3789
|
+
__classPrivateFieldGet(this, _TaroLocation_window, "f").trigger('hashchange');
|
|
3734
3790
|
return true;
|
|
3735
3791
|
}
|
|
3736
|
-
__classPrivateFieldGet(this,
|
|
3792
|
+
__classPrivateFieldGet(this, _TaroLocation_instances, "m", _TaroLocation_rollBack).call(this, preValue.href);
|
|
3737
3793
|
return false;
|
|
3738
3794
|
};
|
|
3795
|
+
const Location = process.env.TARO_PLATFORM === 'web' ? env.window.Location : TaroLocation;
|
|
3739
3796
|
function generateFullUrl(val = '') {
|
|
3740
3797
|
const origin = INIT_URL;
|
|
3741
3798
|
if (/^[/?#]/.test(val)) {
|
|
@@ -3748,7 +3805,7 @@ const machine = 'Macintosh';
|
|
|
3748
3805
|
const arch = 'Intel Mac OS X 10_14_5';
|
|
3749
3806
|
const engine = 'AppleWebKit/534.36 (KHTML, like Gecko) NodeJS/v4.1.0 Chrome/76.0.3809.132 Safari/534.36';
|
|
3750
3807
|
const msg = '(' + machine + '; ' + arch + ') ' + engine;
|
|
3751
|
-
const nav =
|
|
3808
|
+
const nav = process.env.TARO_PLATFORM === 'web' ? env.window.navigator : {
|
|
3752
3809
|
appCodeName: 'Mozilla',
|
|
3753
3810
|
appName: 'Netscape',
|
|
3754
3811
|
appVersion: '5.0 ' + msg,
|
|
@@ -3795,88 +3852,83 @@ const _caf = typeof cancelAnimationFrame !== 'undefined' && cancelAnimationFrame
|
|
|
3795
3852
|
clearTimeout(seed);
|
|
3796
3853
|
};
|
|
3797
3854
|
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
3821
|
-
console.warn(`[Taro warn] window.${String(property)} 在赋值到 window 时报错`);
|
|
3822
|
-
}
|
|
3855
|
+
class TaroWindow extends Events {
|
|
3856
|
+
constructor() {
|
|
3857
|
+
super();
|
|
3858
|
+
this.navigator = nav;
|
|
3859
|
+
this.requestAnimationFrame = _raf;
|
|
3860
|
+
this.cancelAnimationFrame = _caf;
|
|
3861
|
+
this.getComputedStyle = getComputedStyle;
|
|
3862
|
+
const globalProperties = [
|
|
3863
|
+
...Object.getOwnPropertyNames(global || {}),
|
|
3864
|
+
...Object.getOwnPropertySymbols(global || {})
|
|
3865
|
+
];
|
|
3866
|
+
globalProperties.forEach(property => {
|
|
3867
|
+
if (property === 'atob' || property === 'document')
|
|
3868
|
+
return;
|
|
3869
|
+
if (!Object.prototype.hasOwnProperty.call(this, property)) {
|
|
3870
|
+
// 防止小程序环境下,window 上的某些 get 属性在赋值时报错
|
|
3871
|
+
try {
|
|
3872
|
+
this[property] = global[property];
|
|
3873
|
+
}
|
|
3874
|
+
catch (e) {
|
|
3875
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3876
|
+
console.warn(`[Taro warn] window.${String(property)} 在赋值到 window 时报错`);
|
|
3823
3877
|
}
|
|
3824
3878
|
}
|
|
3825
|
-
}
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
}
|
|
3832
|
-
initEvent()
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3879
|
+
}
|
|
3880
|
+
});
|
|
3881
|
+
this.Date || (this.Date = Date);
|
|
3882
|
+
// 应用启动时,提供给需要读取历史信息的库使用
|
|
3883
|
+
this.location = new Location({ window: this });
|
|
3884
|
+
// @ts-ignore
|
|
3885
|
+
this.history = new History(this.location, { window: this });
|
|
3886
|
+
this.initEvent();
|
|
3887
|
+
}
|
|
3888
|
+
initEvent() {
|
|
3889
|
+
const _location = this.location;
|
|
3890
|
+
const _history = this.history;
|
|
3891
|
+
this.on(CONTEXT_ACTIONS.INIT, (pageId) => {
|
|
3892
|
+
// 页面onload,为该页面建立新的上下文信息
|
|
3893
|
+
_location.trigger(CONTEXT_ACTIONS.INIT, pageId);
|
|
3894
|
+
}, null);
|
|
3895
|
+
this.on(CONTEXT_ACTIONS.RECOVER, (pageId) => {
|
|
3896
|
+
// 页面onshow,恢复当前页面的上下文信息
|
|
3897
|
+
_location.trigger(CONTEXT_ACTIONS.RECOVER, pageId);
|
|
3898
|
+
_history.trigger(CONTEXT_ACTIONS.RECOVER, pageId);
|
|
3899
|
+
}, null);
|
|
3900
|
+
this.on(CONTEXT_ACTIONS.RESTORE, (pageId) => {
|
|
3901
|
+
// 页面onhide,缓存当前页面的上下文信息
|
|
3902
|
+
_location.trigger(CONTEXT_ACTIONS.RESTORE, pageId);
|
|
3903
|
+
_history.trigger(CONTEXT_ACTIONS.RESTORE, pageId);
|
|
3904
|
+
}, null);
|
|
3905
|
+
this.on(CONTEXT_ACTIONS.DESTORY, (pageId) => {
|
|
3906
|
+
// 页面onunload,清除当前页面的上下文信息
|
|
3907
|
+
_location.trigger(CONTEXT_ACTIONS.DESTORY, pageId);
|
|
3908
|
+
_history.trigger(CONTEXT_ACTIONS.DESTORY, pageId);
|
|
3909
|
+
}, null);
|
|
3910
|
+
}
|
|
3911
|
+
get document() {
|
|
3912
|
+
return env.document;
|
|
3913
|
+
}
|
|
3914
|
+
addEventListener(event, callback) {
|
|
3915
|
+
if (!isString(event))
|
|
3916
|
+
return;
|
|
3917
|
+
this.on(event, callback, null);
|
|
3918
|
+
}
|
|
3919
|
+
removeEventListener(event, callback) {
|
|
3920
|
+
if (!isString(event))
|
|
3921
|
+
return;
|
|
3922
|
+
this.off(event, callback, null);
|
|
3923
|
+
}
|
|
3924
|
+
setTimeout(...args) {
|
|
3925
|
+
return setTimeout(...args);
|
|
3926
|
+
}
|
|
3927
|
+
clearTimeout(...args) {
|
|
3928
|
+
return clearTimeout(...args);
|
|
3874
3929
|
}
|
|
3875
|
-
window$1 = env.window = new Window();
|
|
3876
|
-
}
|
|
3877
|
-
else {
|
|
3878
|
-
window$1 = env.window;
|
|
3879
3930
|
}
|
|
3931
|
+
const window$1 = process.env.TARO_PLATFORM === 'web' ? env.window : (env.window = new TaroWindow());
|
|
3880
3932
|
const location = window$1.location;
|
|
3881
3933
|
const history = window$1.history;
|
|
3882
3934
|
|
|
@@ -3884,10 +3936,29 @@ const history = window$1.history;
|
|
|
3884
3936
|
class SVGElement extends TaroElement {
|
|
3885
3937
|
}
|
|
3886
3938
|
|
|
3939
|
+
// export const removeLeadingSlash = (str = '') => str.replace(/^\.?\//, '')
|
|
3940
|
+
// export const removeTrailingSearch = (str = '') => str.replace(/\?[\s\S]*$/, '')
|
|
3941
|
+
const addLeadingSlash = (url = '') => (url.charAt(0) === '/' ? url : '/' + url);
|
|
3942
|
+
const hasBasename = (path = '', prefix = '') => new RegExp('^' + prefix + '(\\/|\\?|#|$)', 'i').test(path) || path === prefix;
|
|
3943
|
+
const stripBasename = (path = '', prefix = '') => hasBasename(path, prefix) ? path.substring(prefix.length) : path;
|
|
3944
|
+
const stripTrailing = (str = '') => str.replace(/[?#][\s\S]*$/, '');
|
|
3945
|
+
const stripSuffix = (path = '', suffix = '') => path.includes(suffix) ? path.substring(0, path.length - suffix.length) : path;
|
|
3946
|
+
const getHomePage = (path = '', basename = '', customRoutes = {}, entryPagePath = '') => {
|
|
3947
|
+
var _a;
|
|
3948
|
+
const routePath = addLeadingSlash(stripBasename(path, basename));
|
|
3949
|
+
const alias = ((_a = Object.entries(customRoutes).find(([key]) => key === routePath)) === null || _a === void 0 ? void 0 : _a[1]) || routePath;
|
|
3950
|
+
return entryPagePath || (typeof alias === 'string' ? alias : alias[0]) || basename;
|
|
3951
|
+
};
|
|
3952
|
+
const getCurrentPage = (routerMode = 'hash', basename = '/') => {
|
|
3953
|
+
const pagePath = routerMode === 'hash'
|
|
3954
|
+
? location.hash.slice(1).split('?')[0]
|
|
3955
|
+
: location.pathname;
|
|
3956
|
+
return addLeadingSlash(stripBasename(pagePath, basename));
|
|
3957
|
+
};
|
|
3958
|
+
|
|
3887
3959
|
/* eslint-disable dot-notation */
|
|
3888
3960
|
const instances = new Map();
|
|
3889
3961
|
const pageId = incrementId();
|
|
3890
|
-
const isWeb = isWebPlatform();
|
|
3891
3962
|
function injectPageInstance(inst, id) {
|
|
3892
3963
|
hooks.call('mergePageInstance', instances.get(id), inst);
|
|
3893
3964
|
instances.set(id, inst);
|
|
@@ -3898,12 +3969,6 @@ function getPageInstance(id) {
|
|
|
3898
3969
|
function removePageInstance(id) {
|
|
3899
3970
|
instances.delete(id);
|
|
3900
3971
|
}
|
|
3901
|
-
function addLeadingSlash(path) {
|
|
3902
|
-
if (path == null) {
|
|
3903
|
-
return '';
|
|
3904
|
-
}
|
|
3905
|
-
return path.charAt(0) === '/' ? path : '/' + path;
|
|
3906
|
-
}
|
|
3907
3972
|
function safeExecute(path, lifecycle, ...args) {
|
|
3908
3973
|
const instance = instances.get(path);
|
|
3909
3974
|
if (instance == null) {
|
|
@@ -3930,7 +3995,7 @@ function stringify(obj) {
|
|
|
3930
3995
|
}
|
|
3931
3996
|
function getPath(id, options) {
|
|
3932
3997
|
const idx = id.indexOf('?');
|
|
3933
|
-
if (
|
|
3998
|
+
if (process.env.TARO_PLATFORM === 'web') {
|
|
3934
3999
|
return `${idx > -1 ? id.substring(0, idx) : id}${stringify((options === null || options === void 0 ? void 0 : options.stamp) ? { stamp: options.stamp } : {})}`;
|
|
3935
4000
|
}
|
|
3936
4001
|
else {
|
|
@@ -3954,7 +4019,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
3954
4019
|
let unmounting = false;
|
|
3955
4020
|
let prepareMountList = [];
|
|
3956
4021
|
function setCurrentRouter(page) {
|
|
3957
|
-
const router =
|
|
4022
|
+
const router = process.env.TARO_PLATFORM === 'web' ? page.$taroPath : page.route || page.__route__ || page.$taroPath;
|
|
3958
4023
|
Current.router = {
|
|
3959
4024
|
params: page.$taroParams,
|
|
3960
4025
|
path: addLeadingSlash(router),
|
|
@@ -3978,7 +4043,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
3978
4043
|
// this.$taroPath 是页面唯一标识
|
|
3979
4044
|
const uniqueOptions = Object.assign({}, options, { $taroTimestamp: Date.now() });
|
|
3980
4045
|
const $taroPath = this.$taroPath = getPath(id, uniqueOptions);
|
|
3981
|
-
if (
|
|
4046
|
+
if (process.env.TARO_PLATFORM === 'web') {
|
|
3982
4047
|
config.path = $taroPath;
|
|
3983
4048
|
}
|
|
3984
4049
|
// this.$taroParams 作为暴露给开发者的页面参数对象,可以被随意修改
|
|
@@ -3987,7 +4052,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
3987
4052
|
}
|
|
3988
4053
|
setCurrentRouter(this);
|
|
3989
4054
|
// 初始化当前页面的上下文信息
|
|
3990
|
-
if (
|
|
4055
|
+
if (process.env.TARO_PLATFORM !== 'web') {
|
|
3991
4056
|
window$1.trigger(CONTEXT_ACTIONS.INIT, $taroPath);
|
|
3992
4057
|
}
|
|
3993
4058
|
const mount = () => {
|
|
@@ -3996,7 +4061,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
3996
4061
|
ensure(pageElement !== null, '没有找到页面实例。');
|
|
3997
4062
|
safeExecute($taroPath, ON_LOAD, this.$taroParams);
|
|
3998
4063
|
loadResolver();
|
|
3999
|
-
if (
|
|
4064
|
+
if (process.env.TARO_PLATFORM !== 'web') {
|
|
4000
4065
|
pageElement.ctx = this;
|
|
4001
4066
|
pageElement.performUpdate(true, cb);
|
|
4002
4067
|
}
|
|
@@ -4015,7 +4080,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
4015
4080
|
[ONUNLOAD]() {
|
|
4016
4081
|
const $taroPath = this.$taroPath;
|
|
4017
4082
|
// 销毁当前页面的上下文信息
|
|
4018
|
-
if (
|
|
4083
|
+
if (process.env.TARO_PLATFORM !== 'web') {
|
|
4019
4084
|
window$1.trigger(CONTEXT_ACTIONS.DESTORY, $taroPath);
|
|
4020
4085
|
}
|
|
4021
4086
|
// 触发onUnload生命周期
|
|
@@ -4049,7 +4114,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
4049
4114
|
Current.page = this;
|
|
4050
4115
|
setCurrentRouter(this);
|
|
4051
4116
|
// 恢复上下文信息
|
|
4052
|
-
if (
|
|
4117
|
+
if (process.env.TARO_PLATFORM !== 'web') {
|
|
4053
4118
|
window$1.trigger(CONTEXT_ACTIONS.RECOVER, this.$taroPath);
|
|
4054
4119
|
}
|
|
4055
4120
|
// 触发生命周期
|
|
@@ -4060,7 +4125,7 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
4060
4125
|
},
|
|
4061
4126
|
[ONHIDE]() {
|
|
4062
4127
|
// 缓存当前页面上下文信息
|
|
4063
|
-
if (
|
|
4128
|
+
if (process.env.TARO_PLATFORM !== 'web') {
|
|
4064
4129
|
window$1.trigger(CONTEXT_ACTIONS.RESTORE, this.$taroPath);
|
|
4065
4130
|
}
|
|
4066
4131
|
// 设置 Current 的 page 和 router
|
|
@@ -4074,6 +4139,11 @@ function createPageConfig(component, pageName, data, pageConfig) {
|
|
|
4074
4139
|
eventCenter.trigger(getOnHideEventKey(id));
|
|
4075
4140
|
}
|
|
4076
4141
|
};
|
|
4142
|
+
if (process.env.TARO_PLATFORM === 'web') {
|
|
4143
|
+
config.getOpenerEventChannel = () => {
|
|
4144
|
+
return EventChannel.pageChannel;
|
|
4145
|
+
};
|
|
4146
|
+
}
|
|
4077
4147
|
LIFECYCLES.forEach((lifecycle) => {
|
|
4078
4148
|
let isDefer = false;
|
|
4079
4149
|
lifecycle = lifecycle.replace(/^defer:/, () => {
|
|
@@ -4133,7 +4203,7 @@ function createComponentConfig(component, componentName, data) {
|
|
|
4133
4203
|
ensure(componentElement !== null, '没有找到组件实例。');
|
|
4134
4204
|
this.$taroInstances = instances.get(path);
|
|
4135
4205
|
safeExecute(path, ON_LOAD);
|
|
4136
|
-
if (
|
|
4206
|
+
if (process.env.TARO_PLATFORM !== 'web') {
|
|
4137
4207
|
componentElement.ctx = this;
|
|
4138
4208
|
componentElement.performUpdate(true);
|
|
4139
4209
|
}
|
|
@@ -4231,7 +4301,7 @@ const nextTick = (cb, ctx) => {
|
|
|
4231
4301
|
var _a, _b, _c;
|
|
4232
4302
|
const pageElement = env.document.getElementById(path);
|
|
4233
4303
|
if (pageElement === null || pageElement === void 0 ? void 0 : pageElement.pendingUpdate) {
|
|
4234
|
-
if (
|
|
4304
|
+
if (process.env.TARO_PLATFORM === 'web') {
|
|
4235
4305
|
// eslint-disable-next-line dot-notation
|
|
4236
4306
|
(_c = (_b = (_a = pageElement.firstChild) === null || _a === void 0 ? void 0 : _a['componentOnReady']) === null || _b === void 0 ? void 0 : _b.call(_a).then(() => {
|
|
4237
4307
|
timerFunc();
|
|
@@ -4251,5 +4321,775 @@ const nextTick = (cb, ctx) => {
|
|
|
4251
4321
|
next();
|
|
4252
4322
|
};
|
|
4253
4323
|
|
|
4254
|
-
|
|
4324
|
+
function handleArrayFindPolyfill() {
|
|
4325
|
+
if (!isFunction(Array.prototype.find)) {
|
|
4326
|
+
Object.defineProperty(Array.prototype, 'find', {
|
|
4327
|
+
value(predicate) {
|
|
4328
|
+
if (this == null) {
|
|
4329
|
+
throw new TypeError('"this" is null or not defined');
|
|
4330
|
+
}
|
|
4331
|
+
const o = Object(this);
|
|
4332
|
+
const len = o.length >>> 0;
|
|
4333
|
+
if (!isFunction(predicate)) {
|
|
4334
|
+
throw new TypeError('predicate must be a function');
|
|
4335
|
+
}
|
|
4336
|
+
const thisArg = arguments[1];
|
|
4337
|
+
let k = 0;
|
|
4338
|
+
while (k < len) {
|
|
4339
|
+
const kValue = o[k];
|
|
4340
|
+
if (predicate.call(thisArg, kValue, k, o)) {
|
|
4341
|
+
return kValue;
|
|
4342
|
+
}
|
|
4343
|
+
k++;
|
|
4344
|
+
}
|
|
4345
|
+
return undefined;
|
|
4346
|
+
}
|
|
4347
|
+
});
|
|
4348
|
+
}
|
|
4349
|
+
}
|
|
4350
|
+
function handleArrayIncludesPolyfill() {
|
|
4351
|
+
if (!isFunction(Array.prototype.includes)) {
|
|
4352
|
+
Object.defineProperty(Array.prototype, 'includes', {
|
|
4353
|
+
value(searchElement, fromIndex) {
|
|
4354
|
+
if (this == null) {
|
|
4355
|
+
throw new TypeError('"this" is null or not defined');
|
|
4356
|
+
}
|
|
4357
|
+
const o = Object(this);
|
|
4358
|
+
const len = o.length >>> 0;
|
|
4359
|
+
if (len === 0) {
|
|
4360
|
+
return false;
|
|
4361
|
+
}
|
|
4362
|
+
const n = fromIndex | 0;
|
|
4363
|
+
let k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
|
|
4364
|
+
while (k < len) {
|
|
4365
|
+
if (o[k] === searchElement) {
|
|
4366
|
+
return true;
|
|
4367
|
+
}
|
|
4368
|
+
k++;
|
|
4369
|
+
}
|
|
4370
|
+
return false;
|
|
4371
|
+
}
|
|
4372
|
+
});
|
|
4373
|
+
}
|
|
4374
|
+
}
|
|
4375
|
+
|
|
4376
|
+
/* eslint-disable eqeqeq */
|
|
4377
|
+
function handleIntersectionObserverPolyfill() {
|
|
4378
|
+
// Exit early if all IntersectionObserver and IntersectionObserverEntry
|
|
4379
|
+
// features are natively supported.
|
|
4380
|
+
if ('IntersectionObserver' in window &&
|
|
4381
|
+
'IntersectionObserverEntry' in window &&
|
|
4382
|
+
'intersectionRatio' in window.IntersectionObserverEntry.prototype) {
|
|
4383
|
+
if (!('isIntersecting' in window.IntersectionObserverEntry.prototype)) {
|
|
4384
|
+
// Minimal polyfill for Edge 15's lack of `isIntersecting`
|
|
4385
|
+
// See: https://github.com/w3c/IntersectionObserver/issues/211
|
|
4386
|
+
Object.defineProperty(window.IntersectionObserverEntry.prototype, 'isIntersecting', {
|
|
4387
|
+
get: function () {
|
|
4388
|
+
return this.intersectionRatio > 0;
|
|
4389
|
+
}
|
|
4390
|
+
});
|
|
4391
|
+
}
|
|
4392
|
+
}
|
|
4393
|
+
else {
|
|
4394
|
+
handleIntersectionObserverObjectPolyfill();
|
|
4395
|
+
}
|
|
4396
|
+
}
|
|
4397
|
+
function handleIntersectionObserverObjectPolyfill() {
|
|
4398
|
+
const document = window.document;
|
|
4399
|
+
/**
|
|
4400
|
+
* Creates the global IntersectionObserverEntry constructor.
|
|
4401
|
+
* https://w3c.github.io/IntersectionObserver/#intersection-observer-entry
|
|
4402
|
+
* @param {Object} entry A dictionary of instance properties.
|
|
4403
|
+
* @constructor
|
|
4404
|
+
*/
|
|
4405
|
+
function IntersectionObserverEntry(entry) {
|
|
4406
|
+
this.time = entry.time;
|
|
4407
|
+
this.target = entry.target;
|
|
4408
|
+
this.rootBounds = entry.rootBounds;
|
|
4409
|
+
this.boundingClientRect = entry.boundingClientRect;
|
|
4410
|
+
this.intersectionRect = entry.intersectionRect || getEmptyRect();
|
|
4411
|
+
this.isIntersecting = !!entry.intersectionRect;
|
|
4412
|
+
// Calculates the intersection ratio.
|
|
4413
|
+
const targetRect = this.boundingClientRect;
|
|
4414
|
+
const targetArea = targetRect.width * targetRect.height;
|
|
4415
|
+
const intersectionRect = this.intersectionRect;
|
|
4416
|
+
const intersectionArea = intersectionRect.width * intersectionRect.height;
|
|
4417
|
+
// Sets intersection ratio.
|
|
4418
|
+
if (targetArea) {
|
|
4419
|
+
// Round the intersection ratio to avoid floating point math issues:
|
|
4420
|
+
// https://github.com/w3c/IntersectionObserver/issues/324
|
|
4421
|
+
this.intersectionRatio = Number((intersectionArea / targetArea).toFixed(4));
|
|
4422
|
+
}
|
|
4423
|
+
else {
|
|
4424
|
+
// If area is zero and is intersecting, sets to 1, otherwise to 0
|
|
4425
|
+
this.intersectionRatio = this.isIntersecting ? 1 : 0;
|
|
4426
|
+
}
|
|
4427
|
+
}
|
|
4428
|
+
/**
|
|
4429
|
+
* Creates the global IntersectionObserver constructor.
|
|
4430
|
+
* https://w3c.github.io/IntersectionObserver/#intersection-observer-interface
|
|
4431
|
+
* @param {Function} callback The function to be invoked after intersection
|
|
4432
|
+
* changes have queued. The function is not invoked if the queue has
|
|
4433
|
+
* been emptied by calling the `takeRecords` method.
|
|
4434
|
+
* @param {Object=} opt_options Optional configuration options.
|
|
4435
|
+
* @constructor
|
|
4436
|
+
*/
|
|
4437
|
+
function IntersectionObserver(callback, options = {}) {
|
|
4438
|
+
if (!isFunction(callback)) {
|
|
4439
|
+
throw new Error('callback must be a function');
|
|
4440
|
+
}
|
|
4441
|
+
if (options.root && options.root.nodeType != 1) {
|
|
4442
|
+
throw new Error('root must be an Element');
|
|
4443
|
+
}
|
|
4444
|
+
// Binds and throttles `this._checkForIntersections`.
|
|
4445
|
+
this._checkForIntersections = throttle(this._checkForIntersections.bind(this), this.THROTTLE_TIMEOUT);
|
|
4446
|
+
// Private properties.
|
|
4447
|
+
this._callback = callback;
|
|
4448
|
+
this._observationTargets = [];
|
|
4449
|
+
this._queuedEntries = [];
|
|
4450
|
+
this._rootMarginValues = this._parseRootMargin(options.rootMargin);
|
|
4451
|
+
// Public properties.
|
|
4452
|
+
this.thresholds = this._initThresholds(options.threshold);
|
|
4453
|
+
this.root = options.root || null;
|
|
4454
|
+
this.rootMargin = this._rootMarginValues.map(function (margin) {
|
|
4455
|
+
return margin.value + margin.unit;
|
|
4456
|
+
}).join(' ');
|
|
4457
|
+
}
|
|
4458
|
+
/**
|
|
4459
|
+
* The minimum interval within which the document will be checked for
|
|
4460
|
+
* intersection changes.
|
|
4461
|
+
*/
|
|
4462
|
+
IntersectionObserver.prototype.THROTTLE_TIMEOUT = 100;
|
|
4463
|
+
/**
|
|
4464
|
+
* The frequency in which the polyfill polls for intersection changes.
|
|
4465
|
+
* this can be updated on a per instance basis and must be set prior to
|
|
4466
|
+
* calling `observe` on the first target.
|
|
4467
|
+
*/
|
|
4468
|
+
IntersectionObserver.prototype.POLL_INTERVAL = null;
|
|
4469
|
+
/**
|
|
4470
|
+
* Use a mutation observer on the root element
|
|
4471
|
+
* to detect intersection changes.
|
|
4472
|
+
*/
|
|
4473
|
+
IntersectionObserver.prototype.USE_MUTATION_OBSERVER = true;
|
|
4474
|
+
/**
|
|
4475
|
+
* Starts observing a target element for intersection changes based on
|
|
4476
|
+
* the thresholds values.
|
|
4477
|
+
* @param {Element} target The DOM element to observe.
|
|
4478
|
+
*/
|
|
4479
|
+
IntersectionObserver.prototype.observe = function (target) {
|
|
4480
|
+
const isTargetAlreadyObserved = this._observationTargets.some(function (item) {
|
|
4481
|
+
return item.element == target;
|
|
4482
|
+
});
|
|
4483
|
+
if (isTargetAlreadyObserved)
|
|
4484
|
+
return;
|
|
4485
|
+
if (!(target && target.nodeType == 1)) {
|
|
4486
|
+
throw new Error('target must be an Element');
|
|
4487
|
+
}
|
|
4488
|
+
this._registerInstance();
|
|
4489
|
+
this._observationTargets.push({ element: target, entry: null });
|
|
4490
|
+
this._monitorIntersections();
|
|
4491
|
+
this._checkForIntersections();
|
|
4492
|
+
};
|
|
4493
|
+
/**
|
|
4494
|
+
* Stops observing a target element for intersection changes.
|
|
4495
|
+
* @param {Element} target The DOM element to observe.
|
|
4496
|
+
*/
|
|
4497
|
+
IntersectionObserver.prototype.unobserve = function (target) {
|
|
4498
|
+
this._observationTargets =
|
|
4499
|
+
this._observationTargets.filter(function (item) {
|
|
4500
|
+
return item.element != target;
|
|
4501
|
+
});
|
|
4502
|
+
if (!this._observationTargets.length) {
|
|
4503
|
+
this._unmonitorIntersections();
|
|
4504
|
+
this._unregisterInstance();
|
|
4505
|
+
}
|
|
4506
|
+
};
|
|
4507
|
+
/**
|
|
4508
|
+
* Stops observing all target elements for intersection changes.
|
|
4509
|
+
*/
|
|
4510
|
+
IntersectionObserver.prototype.disconnect = function () {
|
|
4511
|
+
this._observationTargets = [];
|
|
4512
|
+
this._unmonitorIntersections();
|
|
4513
|
+
this._unregisterInstance();
|
|
4514
|
+
};
|
|
4515
|
+
/**
|
|
4516
|
+
* Returns any queue entries that have not yet been reported to the
|
|
4517
|
+
* callback and clears the queue. This can be used in conjunction with the
|
|
4518
|
+
* callback to obtain the absolute most up-to-date intersection information.
|
|
4519
|
+
* @return {Array} The currently queued entries.
|
|
4520
|
+
*/
|
|
4521
|
+
IntersectionObserver.prototype.takeRecords = function () {
|
|
4522
|
+
const records = this._queuedEntries.slice();
|
|
4523
|
+
this._queuedEntries = [];
|
|
4524
|
+
return records;
|
|
4525
|
+
};
|
|
4526
|
+
/**
|
|
4527
|
+
* Accepts the threshold value from the user configuration object and
|
|
4528
|
+
* returns a sorted array of unique threshold values. If a value is not
|
|
4529
|
+
* between 0 and 1 and error is thrown.
|
|
4530
|
+
* @private
|
|
4531
|
+
* @param {Array|number=} opt_threshold An optional threshold value or
|
|
4532
|
+
* a list of threshold values, defaulting to [0].
|
|
4533
|
+
* @return {Array} A sorted list of unique and valid threshold values.
|
|
4534
|
+
*/
|
|
4535
|
+
IntersectionObserver.prototype._initThresholds = function (opt_threshold) {
|
|
4536
|
+
let threshold = opt_threshold || [0];
|
|
4537
|
+
if (!Array.isArray(threshold))
|
|
4538
|
+
threshold = [threshold];
|
|
4539
|
+
return threshold.sort().filter(function (t, i, a) {
|
|
4540
|
+
if (!isNumber(t) || isNaN(t) || t < 0 || t > 1) {
|
|
4541
|
+
throw new Error('threshold must be a number between 0 and 1 inclusively');
|
|
4542
|
+
}
|
|
4543
|
+
return t !== a[i - 1];
|
|
4544
|
+
});
|
|
4545
|
+
};
|
|
4546
|
+
/**
|
|
4547
|
+
* Accepts the rootMargin value from the user configuration object
|
|
4548
|
+
* and returns an array of the four margin values as an object containing
|
|
4549
|
+
* the value and unit properties. If any of the values are not properly
|
|
4550
|
+
* formatted or use a unit other than px or %, and error is thrown.
|
|
4551
|
+
* @private
|
|
4552
|
+
* @param {string=} opt_rootMargin An optional rootMargin value,
|
|
4553
|
+
* defaulting to '0px'.
|
|
4554
|
+
* @return {Array<Object>} An array of margin objects with the keys
|
|
4555
|
+
* value and unit.
|
|
4556
|
+
*/
|
|
4557
|
+
IntersectionObserver.prototype._parseRootMargin = function (opt_rootMargin) {
|
|
4558
|
+
const marginString = opt_rootMargin || '0px';
|
|
4559
|
+
const margins = marginString.split(/\s+/).map(function (margin) {
|
|
4560
|
+
const parts = /^(-?\d*\.?\d+)(px|%)$/.exec(margin);
|
|
4561
|
+
if (!parts) {
|
|
4562
|
+
throw new Error('rootMargin must be specified in pixels or percent');
|
|
4563
|
+
}
|
|
4564
|
+
return { value: parseFloat(parts[1]), unit: parts[2] };
|
|
4565
|
+
});
|
|
4566
|
+
// Handles shorthand.
|
|
4567
|
+
margins[1] = margins[1] || margins[0];
|
|
4568
|
+
margins[2] = margins[2] || margins[0];
|
|
4569
|
+
margins[3] = margins[3] || margins[1];
|
|
4570
|
+
return margins;
|
|
4571
|
+
};
|
|
4572
|
+
/**
|
|
4573
|
+
* Starts polling for intersection changes if the polling is not already
|
|
4574
|
+
* happening, and if the page's visibility state is visible.
|
|
4575
|
+
* @private
|
|
4576
|
+
*/
|
|
4577
|
+
IntersectionObserver.prototype._monitorIntersections = function () {
|
|
4578
|
+
if (!this._monitoringIntersections) {
|
|
4579
|
+
this._monitoringIntersections = true;
|
|
4580
|
+
// If a poll interval is set, use polling instead of listening to
|
|
4581
|
+
// resize and scroll events or DOM mutations.
|
|
4582
|
+
if (this.POLL_INTERVAL) {
|
|
4583
|
+
this._monitoringInterval = setInterval(this._checkForIntersections, this.POLL_INTERVAL);
|
|
4584
|
+
}
|
|
4585
|
+
else {
|
|
4586
|
+
addEvent(window, 'resize', this._checkForIntersections, true);
|
|
4587
|
+
addEvent(document, 'scroll', this._checkForIntersections, true);
|
|
4588
|
+
if (this.USE_MUTATION_OBSERVER && 'MutationObserver' in window) {
|
|
4589
|
+
this._domObserver = new MutationObserver(this._checkForIntersections);
|
|
4590
|
+
this._domObserver.observe(document, {
|
|
4591
|
+
attributes: true,
|
|
4592
|
+
childList: true,
|
|
4593
|
+
characterData: true,
|
|
4594
|
+
subtree: true
|
|
4595
|
+
});
|
|
4596
|
+
}
|
|
4597
|
+
}
|
|
4598
|
+
}
|
|
4599
|
+
};
|
|
4600
|
+
/**
|
|
4601
|
+
* Stops polling for intersection changes.
|
|
4602
|
+
* @private
|
|
4603
|
+
*/
|
|
4604
|
+
IntersectionObserver.prototype._unmonitorIntersections = function () {
|
|
4605
|
+
if (this._monitoringIntersections) {
|
|
4606
|
+
this._monitoringIntersections = false;
|
|
4607
|
+
clearInterval(this._monitoringInterval);
|
|
4608
|
+
this._monitoringInterval = null;
|
|
4609
|
+
removeEvent(window, 'resize', this._checkForIntersections, true);
|
|
4610
|
+
removeEvent(document, 'scroll', this._checkForIntersections, true);
|
|
4611
|
+
if (this._domObserver) {
|
|
4612
|
+
this._domObserver.disconnect();
|
|
4613
|
+
this._domObserver = null;
|
|
4614
|
+
}
|
|
4615
|
+
}
|
|
4616
|
+
};
|
|
4617
|
+
/**
|
|
4618
|
+
* Scans each observation target for intersection changes and adds them
|
|
4619
|
+
* to the internal entries queue. If new entries are found, it
|
|
4620
|
+
* schedules the callback to be invoked.
|
|
4621
|
+
* @private
|
|
4622
|
+
*/
|
|
4623
|
+
IntersectionObserver.prototype._checkForIntersections = function () {
|
|
4624
|
+
const rootIsInDom = this._rootIsInDom();
|
|
4625
|
+
const rootRect = rootIsInDom ? this._getRootRect() : getEmptyRect();
|
|
4626
|
+
this._observationTargets.forEach(function (item) {
|
|
4627
|
+
const target = item.element;
|
|
4628
|
+
const targetRect = getBoundingClientRect(target);
|
|
4629
|
+
const rootContainsTarget = this._rootContainsTarget(target);
|
|
4630
|
+
const oldEntry = item.entry;
|
|
4631
|
+
const intersectionRect = rootIsInDom && rootContainsTarget &&
|
|
4632
|
+
this._computeTargetAndRootIntersection(target, rootRect);
|
|
4633
|
+
const newEntry = item.entry = new IntersectionObserverEntry({
|
|
4634
|
+
time: now(),
|
|
4635
|
+
target: target,
|
|
4636
|
+
boundingClientRect: targetRect,
|
|
4637
|
+
rootBounds: rootRect,
|
|
4638
|
+
intersectionRect: intersectionRect,
|
|
4639
|
+
intersectionRatio: -1,
|
|
4640
|
+
isIntersecting: false,
|
|
4641
|
+
});
|
|
4642
|
+
if (!oldEntry) {
|
|
4643
|
+
this._queuedEntries.push(newEntry);
|
|
4644
|
+
}
|
|
4645
|
+
else if (rootIsInDom && rootContainsTarget) {
|
|
4646
|
+
// If the new entry intersection ratio has crossed any of the
|
|
4647
|
+
// thresholds, add a new entry.
|
|
4648
|
+
if (this._hasCrossedThreshold(oldEntry, newEntry)) {
|
|
4649
|
+
this._queuedEntries.push(newEntry);
|
|
4650
|
+
}
|
|
4651
|
+
}
|
|
4652
|
+
else {
|
|
4653
|
+
// If the root is not in the DOM or target is not contained within
|
|
4654
|
+
// root but the previous entry for this target had an intersection,
|
|
4655
|
+
// add a new record indicating removal.
|
|
4656
|
+
if (oldEntry && oldEntry.isIntersecting) {
|
|
4657
|
+
this._queuedEntries.push(newEntry);
|
|
4658
|
+
}
|
|
4659
|
+
}
|
|
4660
|
+
}, this);
|
|
4661
|
+
if (this._queuedEntries.length) {
|
|
4662
|
+
this._callback(this.takeRecords(), this);
|
|
4663
|
+
}
|
|
4664
|
+
};
|
|
4665
|
+
/**
|
|
4666
|
+
* Accepts a target and root rect computes the intersection between then
|
|
4667
|
+
* following the algorithm in the spec.
|
|
4668
|
+
* TODO(philipwalton): at this time clip-path is not considered.
|
|
4669
|
+
* https://w3c.github.io/IntersectionObserver/#calculate-intersection-rect-algo
|
|
4670
|
+
* @param {Element} target The target DOM element
|
|
4671
|
+
* @param {Object} rootRect The bounding rect of the root after being
|
|
4672
|
+
* expanded by the rootMargin value.
|
|
4673
|
+
* @return {?Object} The final intersection rect object or undefined if no
|
|
4674
|
+
* intersection is found.
|
|
4675
|
+
* @private
|
|
4676
|
+
*/
|
|
4677
|
+
IntersectionObserver.prototype._computeTargetAndRootIntersection = function (target, rootRect) {
|
|
4678
|
+
// If the element isn't displayed, an intersection can't happen.
|
|
4679
|
+
if (window.getComputedStyle(target).display === 'none')
|
|
4680
|
+
return;
|
|
4681
|
+
const targetRect = getBoundingClientRect(target);
|
|
4682
|
+
let intersectionRect = targetRect;
|
|
4683
|
+
let parent = getParentNode(target);
|
|
4684
|
+
let atRoot = false;
|
|
4685
|
+
while (!atRoot) {
|
|
4686
|
+
let parentRect = null;
|
|
4687
|
+
const parentComputedStyle = parent.nodeType == 1 ?
|
|
4688
|
+
window.getComputedStyle(parent) : {};
|
|
4689
|
+
// If the parent isn't displayed, an intersection can't happen.
|
|
4690
|
+
if (parentComputedStyle.display === 'none')
|
|
4691
|
+
return;
|
|
4692
|
+
if (parent == this.root || parent == document) {
|
|
4693
|
+
atRoot = true;
|
|
4694
|
+
parentRect = rootRect;
|
|
4695
|
+
}
|
|
4696
|
+
else {
|
|
4697
|
+
// If the element has a non-visible overflow, and it's not the <body>
|
|
4698
|
+
// or <html> element, update the intersection rect.
|
|
4699
|
+
// Note: <body> and <html> cannot be clipped to a rect that's not also
|
|
4700
|
+
// the document rect, so no need to compute a new intersection.
|
|
4701
|
+
if (parent != document.body &&
|
|
4702
|
+
parent != document.documentElement &&
|
|
4703
|
+
parentComputedStyle.overflow != 'visible') {
|
|
4704
|
+
parentRect = getBoundingClientRect(parent);
|
|
4705
|
+
}
|
|
4706
|
+
}
|
|
4707
|
+
// If either of the above conditionals set a new parentRect,
|
|
4708
|
+
// calculate new intersection data.
|
|
4709
|
+
if (parentRect) {
|
|
4710
|
+
intersectionRect = computeRectIntersection(parentRect, intersectionRect);
|
|
4711
|
+
if (!intersectionRect)
|
|
4712
|
+
break;
|
|
4713
|
+
}
|
|
4714
|
+
parent = getParentNode(parent);
|
|
4715
|
+
}
|
|
4716
|
+
return intersectionRect;
|
|
4717
|
+
};
|
|
4718
|
+
/**
|
|
4719
|
+
* Returns the root rect after being expanded by the rootMargin value.
|
|
4720
|
+
* @return {Object} The expanded root rect.
|
|
4721
|
+
* @private
|
|
4722
|
+
*/
|
|
4723
|
+
IntersectionObserver.prototype._getRootRect = function () {
|
|
4724
|
+
let rootRect;
|
|
4725
|
+
if (this.root) {
|
|
4726
|
+
rootRect = getBoundingClientRect(this.root);
|
|
4727
|
+
}
|
|
4728
|
+
else {
|
|
4729
|
+
// Use <html>/<body> instead of window since scroll bars affect size.
|
|
4730
|
+
const html = document.documentElement;
|
|
4731
|
+
const body = document.body;
|
|
4732
|
+
rootRect = {
|
|
4733
|
+
top: 0,
|
|
4734
|
+
left: 0,
|
|
4735
|
+
right: html.clientWidth || body.clientWidth,
|
|
4736
|
+
width: html.clientWidth || body.clientWidth,
|
|
4737
|
+
bottom: html.clientHeight || body.clientHeight,
|
|
4738
|
+
height: html.clientHeight || body.clientHeight
|
|
4739
|
+
};
|
|
4740
|
+
}
|
|
4741
|
+
return this._expandRectByRootMargin(rootRect);
|
|
4742
|
+
};
|
|
4743
|
+
/**
|
|
4744
|
+
* Accepts a rect and expands it by the rootMargin value.
|
|
4745
|
+
* @param {Object} rect The rect object to expand.
|
|
4746
|
+
* @return {Object} The expanded rect.
|
|
4747
|
+
* @private
|
|
4748
|
+
*/
|
|
4749
|
+
IntersectionObserver.prototype._expandRectByRootMargin = function (rect) {
|
|
4750
|
+
const margins = this._rootMarginValues.map(function (margin, i) {
|
|
4751
|
+
return margin.unit === 'px' ? margin.value :
|
|
4752
|
+
margin.value * (i % 2 ? rect.width : rect.height) / 100;
|
|
4753
|
+
});
|
|
4754
|
+
const newRect = {
|
|
4755
|
+
top: rect.top - margins[0],
|
|
4756
|
+
right: rect.right + margins[1],
|
|
4757
|
+
bottom: rect.bottom + margins[2],
|
|
4758
|
+
left: rect.left - margins[3]
|
|
4759
|
+
};
|
|
4760
|
+
newRect.width = newRect.right - newRect.left;
|
|
4761
|
+
newRect.height = newRect.bottom - newRect.top;
|
|
4762
|
+
return newRect;
|
|
4763
|
+
};
|
|
4764
|
+
/**
|
|
4765
|
+
* Accepts an old and new entry and returns true if at least one of the
|
|
4766
|
+
* threshold values has been crossed.
|
|
4767
|
+
* @param {?IntersectionObserverEntry} oldEntry The previous entry for a
|
|
4768
|
+
* particular target element or null if no previous entry exists.
|
|
4769
|
+
* @param {IntersectionObserverEntry} newEntry The current entry for a
|
|
4770
|
+
* particular target element.
|
|
4771
|
+
* @return {boolean} Returns true if a any threshold has been crossed.
|
|
4772
|
+
* @private
|
|
4773
|
+
*/
|
|
4774
|
+
IntersectionObserver.prototype._hasCrossedThreshold =
|
|
4775
|
+
function (oldEntry, newEntry) {
|
|
4776
|
+
// To make comparing easier, an entry that has a ratio of 0
|
|
4777
|
+
// but does not actually intersect is given a value of -1
|
|
4778
|
+
const oldRatio = oldEntry && oldEntry.isIntersecting ? oldEntry.intersectionRatio || 0 : -1;
|
|
4779
|
+
const newRatio = newEntry.isIntersecting ? newEntry.intersectionRatio || 0 : -1;
|
|
4780
|
+
// Ignore unchanged ratios
|
|
4781
|
+
if (oldRatio === newRatio)
|
|
4782
|
+
return;
|
|
4783
|
+
for (let i = 0; i < this.thresholds.length; i++) {
|
|
4784
|
+
const threshold = this.thresholds[i];
|
|
4785
|
+
// Return true if an entry matches a threshold or if the new ratio
|
|
4786
|
+
// and the old ratio are on the opposite sides of a threshold.
|
|
4787
|
+
if (threshold == oldRatio || threshold == newRatio ||
|
|
4788
|
+
threshold < oldRatio !== threshold < newRatio) {
|
|
4789
|
+
return true;
|
|
4790
|
+
}
|
|
4791
|
+
}
|
|
4792
|
+
};
|
|
4793
|
+
/**
|
|
4794
|
+
* Returns whether or not the root element is an element and is in the DOM.
|
|
4795
|
+
* @return {boolean} True if the root element is an element and is in the DOM.
|
|
4796
|
+
* @private
|
|
4797
|
+
*/
|
|
4798
|
+
IntersectionObserver.prototype._rootIsInDom = function () {
|
|
4799
|
+
return !this.root || containsDeep(document, this.root);
|
|
4800
|
+
};
|
|
4801
|
+
/**
|
|
4802
|
+
* Returns whether or not the target element is a child of root.
|
|
4803
|
+
* @param {Element} target The target element to check.
|
|
4804
|
+
* @return {boolean} True if the target element is a child of root.
|
|
4805
|
+
* @private
|
|
4806
|
+
*/
|
|
4807
|
+
IntersectionObserver.prototype._rootContainsTarget = function (target) {
|
|
4808
|
+
return containsDeep(this.root || document, target);
|
|
4809
|
+
};
|
|
4810
|
+
/**
|
|
4811
|
+
* Adds the instance to the global IntersectionObserver registry if it isn't
|
|
4812
|
+
* already present.
|
|
4813
|
+
* @private
|
|
4814
|
+
*/
|
|
4815
|
+
IntersectionObserver.prototype._registerInstance = function () {
|
|
4816
|
+
};
|
|
4817
|
+
/**
|
|
4818
|
+
* Removes the instance from the global IntersectionObserver registry.
|
|
4819
|
+
* @private
|
|
4820
|
+
*/
|
|
4821
|
+
IntersectionObserver.prototype._unregisterInstance = function () {
|
|
4822
|
+
};
|
|
4823
|
+
/**
|
|
4824
|
+
* Returns the result of the performance.now() method or null in browsers
|
|
4825
|
+
* that don't support the API.
|
|
4826
|
+
* @return {number} The elapsed time since the page was requested.
|
|
4827
|
+
*/
|
|
4828
|
+
function now() {
|
|
4829
|
+
return window.performance && performance.now && performance.now();
|
|
4830
|
+
}
|
|
4831
|
+
/**
|
|
4832
|
+
* Adds an event handler to a DOM node ensuring cross-browser compatibility.
|
|
4833
|
+
* @param {Node} node The DOM node to add the event handler to.
|
|
4834
|
+
* @param {string} event The event name.
|
|
4835
|
+
* @param {Function} fn The event handler to add.
|
|
4836
|
+
* @param {boolean} opt_useCapture Optionally adds the even to the capture
|
|
4837
|
+
* phase. Note: this only works in modern browsers.
|
|
4838
|
+
*/
|
|
4839
|
+
function addEvent(node, event, fn, opt_useCapture) {
|
|
4840
|
+
if (isFunction(node.addEventListener)) {
|
|
4841
|
+
node.addEventListener(event, fn, opt_useCapture || false);
|
|
4842
|
+
}
|
|
4843
|
+
else if (isFunction(node.attachEvent)) {
|
|
4844
|
+
node.attachEvent('on' + event, fn);
|
|
4845
|
+
}
|
|
4846
|
+
}
|
|
4847
|
+
/**
|
|
4848
|
+
* Removes a previously added event handler from a DOM node.
|
|
4849
|
+
* @param {Node} node The DOM node to remove the event handler from.
|
|
4850
|
+
* @param {string} event The event name.
|
|
4851
|
+
* @param {Function} fn The event handler to remove.
|
|
4852
|
+
* @param {boolean} opt_useCapture If the event handler was added with this
|
|
4853
|
+
* flag set to true, it should be set to true here in order to remove it.
|
|
4854
|
+
*/
|
|
4855
|
+
function removeEvent(node, event, fn, opt_useCapture) {
|
|
4856
|
+
if (isFunction(node.removeEventListener)) {
|
|
4857
|
+
node.removeEventListener(event, fn, opt_useCapture || false);
|
|
4858
|
+
}
|
|
4859
|
+
else if (isFunction(node.detatchEvent)) {
|
|
4860
|
+
node.detatchEvent('on' + event, fn);
|
|
4861
|
+
}
|
|
4862
|
+
}
|
|
4863
|
+
/**
|
|
4864
|
+
* Returns the intersection between two rect objects.
|
|
4865
|
+
* @param {Object} rect1 The first rect.
|
|
4866
|
+
* @param {Object} rect2 The second rect.
|
|
4867
|
+
* @return {?Object} The intersection rect or undefined if no intersection
|
|
4868
|
+
* is found.
|
|
4869
|
+
*/
|
|
4870
|
+
function computeRectIntersection(rect1, rect2) {
|
|
4871
|
+
const top = Math.max(rect1.top, rect2.top);
|
|
4872
|
+
const bottom = Math.min(rect1.bottom, rect2.bottom);
|
|
4873
|
+
const left = Math.max(rect1.left, rect2.left);
|
|
4874
|
+
const right = Math.min(rect1.right, rect2.right);
|
|
4875
|
+
const width = right - left;
|
|
4876
|
+
const height = bottom - top;
|
|
4877
|
+
return (width >= 0 && height >= 0) && {
|
|
4878
|
+
top: top,
|
|
4879
|
+
bottom: bottom,
|
|
4880
|
+
left: left,
|
|
4881
|
+
right: right,
|
|
4882
|
+
width: width,
|
|
4883
|
+
height: height
|
|
4884
|
+
};
|
|
4885
|
+
}
|
|
4886
|
+
/**
|
|
4887
|
+
* Shims the native getBoundingClientRect for compatibility with older IE.
|
|
4888
|
+
* @param {Element} el The element whose bounding rect to get.
|
|
4889
|
+
* @return {Object} The (possibly shimmed) rect of the element.
|
|
4890
|
+
*/
|
|
4891
|
+
function getBoundingClientRect(el) {
|
|
4892
|
+
let rect;
|
|
4893
|
+
try {
|
|
4894
|
+
rect = el.getBoundingClientRect();
|
|
4895
|
+
}
|
|
4896
|
+
catch (err) {
|
|
4897
|
+
// Ignore Windows 7 IE11 "Unspecified error"
|
|
4898
|
+
// https://github.com/w3c/IntersectionObserver/pull/205
|
|
4899
|
+
}
|
|
4900
|
+
if (!rect)
|
|
4901
|
+
return getEmptyRect();
|
|
4902
|
+
// Older IE
|
|
4903
|
+
if (!(rect.width && rect.height)) {
|
|
4904
|
+
rect = {
|
|
4905
|
+
top: rect.top,
|
|
4906
|
+
right: rect.right,
|
|
4907
|
+
bottom: rect.bottom,
|
|
4908
|
+
left: rect.left,
|
|
4909
|
+
width: rect.right - rect.left,
|
|
4910
|
+
height: rect.bottom - rect.top
|
|
4911
|
+
};
|
|
4912
|
+
}
|
|
4913
|
+
return rect;
|
|
4914
|
+
}
|
|
4915
|
+
/**
|
|
4916
|
+
* Returns an empty rect object. An empty rect is returned when an element
|
|
4917
|
+
* is not in the DOM.
|
|
4918
|
+
* @return {Object} The empty rect.
|
|
4919
|
+
*/
|
|
4920
|
+
function getEmptyRect() {
|
|
4921
|
+
return {
|
|
4922
|
+
top: 0,
|
|
4923
|
+
bottom: 0,
|
|
4924
|
+
left: 0,
|
|
4925
|
+
right: 0,
|
|
4926
|
+
width: 0,
|
|
4927
|
+
height: 0
|
|
4928
|
+
};
|
|
4929
|
+
}
|
|
4930
|
+
/**
|
|
4931
|
+
* Checks to see if a parent element contains a child element (including inside
|
|
4932
|
+
* shadow DOM).
|
|
4933
|
+
* @param {Node} parent The parent element.
|
|
4934
|
+
* @param {Node} child The child element.
|
|
4935
|
+
* @return {boolean} True if the parent node contains the child node.
|
|
4936
|
+
*/
|
|
4937
|
+
function containsDeep(parent, child) {
|
|
4938
|
+
let node = child;
|
|
4939
|
+
while (node) {
|
|
4940
|
+
if (node == parent)
|
|
4941
|
+
return true;
|
|
4942
|
+
node = getParentNode(node);
|
|
4943
|
+
}
|
|
4944
|
+
return false;
|
|
4945
|
+
}
|
|
4946
|
+
/**
|
|
4947
|
+
* Gets the parent node of an element or its host element if the parent node
|
|
4948
|
+
* is a shadow root.
|
|
4949
|
+
* @param {Node} node The node whose parent to get.
|
|
4950
|
+
* @return {Node|null} The parent node or null if no parent exists.
|
|
4951
|
+
*/
|
|
4952
|
+
function getParentNode(node) {
|
|
4953
|
+
const parent = node.parentNode;
|
|
4954
|
+
if (parent && parent.nodeType == 11 && parent.host) {
|
|
4955
|
+
// If the parent is a shadow root, return the host element.
|
|
4956
|
+
return parent.host;
|
|
4957
|
+
}
|
|
4958
|
+
if (parent && parent.assignedSlot) {
|
|
4959
|
+
// If the parent is distributed in a <slot>, return the parent of a slot.
|
|
4960
|
+
return parent.assignedSlot.parentNode;
|
|
4961
|
+
}
|
|
4962
|
+
return parent;
|
|
4963
|
+
}
|
|
4964
|
+
// Exposes the constructors globally.
|
|
4965
|
+
window.IntersectionObserver = IntersectionObserver;
|
|
4966
|
+
window.IntersectionObserverEntry = IntersectionObserverEntry;
|
|
4967
|
+
}
|
|
4968
|
+
|
|
4969
|
+
function handleObjectAssignPolyfill() {
|
|
4970
|
+
if (!isFunction(Object.assign)) {
|
|
4971
|
+
// Must be writable: true, enumerable: false, configurable: true
|
|
4972
|
+
Object.assign = function (target) {
|
|
4973
|
+
if (target == null) { // TypeError if undefined or null
|
|
4974
|
+
throw new TypeError('Cannot convert undefined or null to object');
|
|
4975
|
+
}
|
|
4976
|
+
const to = Object(target);
|
|
4977
|
+
for (let index = 1; index < arguments.length; index++) {
|
|
4978
|
+
const nextSource = arguments[index];
|
|
4979
|
+
if (nextSource != null) { // Skip over if undefined or null
|
|
4980
|
+
for (const nextKey in nextSource) {
|
|
4981
|
+
// Avoid bugs when hasOwnProperty is shadowed
|
|
4982
|
+
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
|
|
4983
|
+
to[nextKey] = nextSource[nextKey];
|
|
4984
|
+
}
|
|
4985
|
+
}
|
|
4986
|
+
}
|
|
4987
|
+
}
|
|
4988
|
+
return to;
|
|
4989
|
+
};
|
|
4990
|
+
}
|
|
4991
|
+
}
|
|
4992
|
+
function handleObjectEntriesPolyfill() {
|
|
4993
|
+
if (!isFunction(Object.entries)) {
|
|
4994
|
+
// Must be writable: true, enumerable: false, configurable: true
|
|
4995
|
+
Object.entries = function (obj) {
|
|
4996
|
+
if (obj == null) { // TypeError if undefined or null
|
|
4997
|
+
throw new TypeError('Cannot convert undefined or null to object');
|
|
4998
|
+
}
|
|
4999
|
+
const to = [];
|
|
5000
|
+
if (obj != null) { // Skip over if undefined or null
|
|
5001
|
+
for (const key in obj) {
|
|
5002
|
+
// Avoid bugs when hasOwnProperty is shadowed
|
|
5003
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
5004
|
+
to.push([key, obj[key]]);
|
|
5005
|
+
}
|
|
5006
|
+
}
|
|
5007
|
+
}
|
|
5008
|
+
return to;
|
|
5009
|
+
};
|
|
5010
|
+
}
|
|
5011
|
+
}
|
|
5012
|
+
function handleObjectDefinePropertyPolyfill() {
|
|
5013
|
+
if (!isFunction(Object.defineProperties)) {
|
|
5014
|
+
Object.defineProperties = function (obj, properties) {
|
|
5015
|
+
function convertToDescriptor(desc) {
|
|
5016
|
+
function hasProperty(obj, prop) {
|
|
5017
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
5018
|
+
}
|
|
5019
|
+
if (!isObject(desc)) {
|
|
5020
|
+
throw new TypeError('bad desc');
|
|
5021
|
+
}
|
|
5022
|
+
const d = {};
|
|
5023
|
+
if (hasProperty(desc, 'enumerable'))
|
|
5024
|
+
d.enumerable = !!desc.enumerable;
|
|
5025
|
+
if (hasProperty(desc, 'configurable')) {
|
|
5026
|
+
d.configurable = !!desc.configurable;
|
|
5027
|
+
}
|
|
5028
|
+
if (hasProperty(desc, 'value'))
|
|
5029
|
+
d.value = desc.value;
|
|
5030
|
+
if (hasProperty(desc, 'writable'))
|
|
5031
|
+
d.writable = !!desc.writable;
|
|
5032
|
+
if (hasProperty(desc, 'get')) {
|
|
5033
|
+
const g = desc.get;
|
|
5034
|
+
if (!isFunction(g) && !isUndefined(g)) {
|
|
5035
|
+
throw new TypeError('bad get');
|
|
5036
|
+
}
|
|
5037
|
+
d.get = g;
|
|
5038
|
+
}
|
|
5039
|
+
if (hasProperty(desc, 'set')) {
|
|
5040
|
+
const s = desc.set;
|
|
5041
|
+
if (!isFunction(s) && !isUndefined(s)) {
|
|
5042
|
+
throw new TypeError('bad set');
|
|
5043
|
+
}
|
|
5044
|
+
d.set = s;
|
|
5045
|
+
}
|
|
5046
|
+
if (('get' in d || 'set' in d) && ('value' in d || 'writable' in d)) {
|
|
5047
|
+
throw new TypeError('identity-confused descriptor');
|
|
5048
|
+
}
|
|
5049
|
+
return d;
|
|
5050
|
+
}
|
|
5051
|
+
if (!isObject(obj))
|
|
5052
|
+
throw new TypeError('bad obj');
|
|
5053
|
+
properties = Object(properties);
|
|
5054
|
+
const keys = Object.keys(properties);
|
|
5055
|
+
const descs = [];
|
|
5056
|
+
for (let i = 0; i < keys.length; i++) {
|
|
5057
|
+
descs.push([keys[i], convertToDescriptor(properties[keys[i]])]);
|
|
5058
|
+
}
|
|
5059
|
+
for (let i = 0; i < descs.length; i++) {
|
|
5060
|
+
Object.defineProperty(obj, descs[i][0], descs[i][1]);
|
|
5061
|
+
}
|
|
5062
|
+
return obj;
|
|
5063
|
+
};
|
|
5064
|
+
}
|
|
5065
|
+
}
|
|
5066
|
+
|
|
5067
|
+
function handlePolyfill() {
|
|
5068
|
+
if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Object' || process.env.SUPPORT_TARO_POLYFILL === 'Object.assign') {
|
|
5069
|
+
handleObjectAssignPolyfill();
|
|
5070
|
+
}
|
|
5071
|
+
if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Object' || process.env.SUPPORT_TARO_POLYFILL === 'Object.entries') {
|
|
5072
|
+
handleObjectEntriesPolyfill();
|
|
5073
|
+
}
|
|
5074
|
+
if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Object' || process.env.SUPPORT_TARO_POLYFILL === 'Object.defineProperty') {
|
|
5075
|
+
handleObjectDefinePropertyPolyfill();
|
|
5076
|
+
}
|
|
5077
|
+
if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Array' || process.env.SUPPORT_TARO_POLYFILL === 'Array.find') {
|
|
5078
|
+
handleArrayFindPolyfill();
|
|
5079
|
+
}
|
|
5080
|
+
if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'Array' || process.env.SUPPORT_TARO_POLYFILL === 'Array.includes') {
|
|
5081
|
+
handleArrayIncludesPolyfill();
|
|
5082
|
+
}
|
|
5083
|
+
// Exit early if we're not running in a browser.
|
|
5084
|
+
if (process.env.TARO_PLATFORM === 'web' && isObject(window)) {
|
|
5085
|
+
if (process.env.SUPPORT_TARO_POLYFILL === 'enabled' || process.env.SUPPORT_TARO_POLYFILL === 'IntersectionObserver') {
|
|
5086
|
+
handleIntersectionObserverPolyfill();
|
|
5087
|
+
}
|
|
5088
|
+
}
|
|
5089
|
+
}
|
|
5090
|
+
if (process.env.SUPPORT_TARO_POLYFILL !== 'disabled' && process.env.TARO_PLATFORM !== 'web') {
|
|
5091
|
+
handlePolyfill();
|
|
5092
|
+
}
|
|
5093
|
+
|
|
5094
|
+
export { A, APP, BEHAVIORS, BODY, CATCHMOVE, CATCH_VIEW, CHANGE, CLASS, COMMENT, COMPILE_MODE, 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$1 as 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, getCurrentPage, getHomePage, getOnHideEventKey, getOnReadyEventKey, getOnShowEventKey, getPageInstance, getPath, handlePolyfill, hasBasename, history, hydrate, incrementId, injectPageInstance, isHasExtractProp, location, nav as navigator, nextTick, now, options, parseUrl, removePageInstance, _raf as requestAnimationFrame, safeExecute, stringify, stripBasename, stripSuffix, stripTrailing, window$1 as window };
|
|
4255
5095
|
//# sourceMappingURL=runtime.esm.js.map
|