@tarojs/runtime 4.1.12-beta.34 → 4.1.12-beta.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dom/nearest-ctx.js
CHANGED
|
@@ -37,7 +37,12 @@ function resolveNearestCtxValue(node, root) {
|
|
|
37
37
|
return (_a = root.ctx) !== null && _a !== void 0 ? _a : null;
|
|
38
38
|
}
|
|
39
39
|
function bumpNearestCtxEpochForRoot(root) {
|
|
40
|
-
|
|
40
|
+
if (!isNearestCtxEnv() || root == null) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (typeof root.bumpNearestCtxEpoch === 'function') {
|
|
44
|
+
root.bumpNearestCtxEpoch();
|
|
45
|
+
}
|
|
41
46
|
}
|
|
42
47
|
|
|
43
48
|
export { bumpNearestCtxEpochForRoot, getNearestCtx, isNearestCtxEnv };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nearest-ctx.js","sources":["../../../src/dom/nearest-ctx.ts"],"sourcesContent":["import { NodeType } from './node_types'\n\nimport type { MpInstance } from '../interface'\nimport type { TaroElement } from './element'\nimport type { TaroNode } from './node'\nimport type { TaroRootElement } from './root'\n\nconst nearestCtxCache = new WeakMap<TaroNode, { value: MpInstance | null, nearestCtxEpoch: number }>()\n\nexport function isNearestCtxEnv (): boolean {\n return process.env.TARO_ENV === 'weapp' || process.env.TARO_ENV === 'jd'\n}\n\nexport function getNearestCtx (node: TaroNode): MpInstance | null | undefined {\n if (!isNearestCtxEnv()) {\n return undefined\n }\n const root = node._root\n if (root == null) {\n return null\n }\n const cached = nearestCtxCache.get(node)\n if (cached && cached.nearestCtxEpoch === root.nearestCtxEpoch) {\n return cached.value\n }\n const value = resolveNearestCtxValue(node, root)\n nearestCtxCache.set(node, { value, nearestCtxEpoch: root.nearestCtxEpoch })\n return value\n}\n\nfunction resolveNearestCtxValue (node: TaroNode, root: TaroRootElement): MpInstance | null {\n if (node.nodeType === NodeType.ELEMENT_NODE) {\n const ctx = (node as TaroElement).ctx\n if (ctx != null) return ctx as MpInstance\n }\n let current: TaroNode | null = node.parentNode\n while (current) {\n if (current.nodeType === NodeType.ELEMENT_NODE) {\n const ctx = (current as TaroElement).ctx\n if (ctx != null) return ctx as MpInstance\n }\n current = current.parentNode\n }\n return root.ctx ?? null\n}\n\nexport function bumpNearestCtxEpochForRoot (root: TaroRootElement | null | undefined): void {\n root
|
|
1
|
+
{"version":3,"file":"nearest-ctx.js","sources":["../../../src/dom/nearest-ctx.ts"],"sourcesContent":["import { NodeType } from './node_types'\n\nimport type { MpInstance } from '../interface'\nimport type { TaroElement } from './element'\nimport type { TaroNode } from './node'\nimport type { TaroRootElement } from './root'\n\nconst nearestCtxCache = new WeakMap<TaroNode, { value: MpInstance | null, nearestCtxEpoch: number }>()\n\nexport function isNearestCtxEnv (): boolean {\n return process.env.TARO_ENV === 'weapp' || process.env.TARO_ENV === 'jd'\n}\n\nexport function getNearestCtx (node: TaroNode): MpInstance | null | undefined {\n if (!isNearestCtxEnv()) {\n return undefined\n }\n const root = node._root\n if (root == null) {\n return null\n }\n const cached = nearestCtxCache.get(node)\n if (cached && cached.nearestCtxEpoch === root.nearestCtxEpoch) {\n return cached.value\n }\n const value = resolveNearestCtxValue(node, root)\n nearestCtxCache.set(node, { value, nearestCtxEpoch: root.nearestCtxEpoch })\n return value\n}\n\nfunction resolveNearestCtxValue (node: TaroNode, root: TaroRootElement): MpInstance | null {\n if (node.nodeType === NodeType.ELEMENT_NODE) {\n const ctx = (node as TaroElement).ctx\n if (ctx != null) return ctx as MpInstance\n }\n let current: TaroNode | null = node.parentNode\n while (current) {\n if (current.nodeType === NodeType.ELEMENT_NODE) {\n const ctx = (current as TaroElement).ctx\n if (ctx != null) return ctx as MpInstance\n }\n current = current.parentNode\n }\n return root.ctx ?? null\n}\n\nexport function bumpNearestCtxEpochForRoot (root: TaroRootElement | null | undefined): void {\n if (!isNearestCtxEnv() || root == null) {\n return\n }\n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B,CAAC,GAAG;YACxC,IAAI,GAAG,IAAI,IAAI;AAAE,gBAAA,OAAO,GAAiB;;AAE3C,QAAA,OAAO,GAAG,OAAO,CAAC,UAAU;;AAE9B,IAAA,OAAO,MAAA,IAAI,CAAC,GAAG,MAAA,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,EAAA,GAAI,IAAI;AACzB;AAEM,SAAU,0BAA0B,CAAE,IAAwC,EAAA;IAClF,IAAI,CAAC,eAAe,EAAE,IAAI,IAAI,IAAI,IAAI,EAAE;QACtC;;AAEF,IAAA,IAAI,OAAO,IAAI,CAAC,mBAAmB,KAAK,UAAU,EAAE;QAClD,IAAI,CAAC,mBAAmB,EAAE;;AAE9B;;;;"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -1512,7 +1512,12 @@ function resolveNearestCtxValue(node, root) {
|
|
|
1512
1512
|
return (_a = root.ctx) !== null && _a !== void 0 ? _a : null;
|
|
1513
1513
|
}
|
|
1514
1514
|
function bumpNearestCtxEpochForRoot(root) {
|
|
1515
|
-
|
|
1515
|
+
if (!isNearestCtxEnv() || root == null) {
|
|
1516
|
+
return;
|
|
1517
|
+
}
|
|
1518
|
+
if (typeof root.bumpNearestCtxEpoch === 'function') {
|
|
1519
|
+
root.bumpNearestCtxEpoch();
|
|
1520
|
+
}
|
|
1516
1521
|
}
|
|
1517
1522
|
|
|
1518
1523
|
const CHILDNODES = "cn" /* Shortcuts.Childnodes */;
|