@viewfly/core 3.0.0-alpha.3 → 3.0.0-alpha.4
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/base/_utils.d.ts +0 -1
- package/dist/base/component.d.ts +1 -1
- package/dist/index.esm.js +31 -38
- package/dist/index.js +31 -38
- package/package.json +1 -1
package/dist/base/_utils.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Key, ViewFlyNode } from './jsx-element';
|
|
2
2
|
import { NativeNode } from './injection-tokens';
|
|
3
3
|
import { Component, ComponentSetup } from './component';
|
|
4
|
-
export declare function hasChange(newProps: Record<string, any>, oldProps: Record<string, any>): boolean;
|
|
5
4
|
export declare const refKey = "ref";
|
|
6
5
|
export declare function comparePropsWithCallbacks(oldProps: Record<string, any>, newProps: Record<string, any>, onDeleted: (key: string, oldValue: any) => void, onAdded: (key: string, value: any) => void, onUpdated: (key: string, newValue: any, oldValue: any) => void): void;
|
|
7
6
|
export declare function classToString(config: unknown): string;
|
package/dist/base/component.d.ts
CHANGED
package/dist/index.esm.js
CHANGED
|
@@ -1271,17 +1271,6 @@ function reactive(raw) {
|
|
|
1271
1271
|
}
|
|
1272
1272
|
//#endregion
|
|
1273
1273
|
//#region src/base/_utils.ts
|
|
1274
|
-
function hasChange(newProps, oldProps) {
|
|
1275
|
-
const newKeys = Object.keys(oldProps);
|
|
1276
|
-
const oldKeys = Object.keys(newProps);
|
|
1277
|
-
if (oldKeys.length !== newKeys.length) return true;
|
|
1278
|
-
const len = oldKeys.length;
|
|
1279
|
-
for (let i = 0; i < len; i++) {
|
|
1280
|
-
const key = newKeys[i];
|
|
1281
|
-
if (newProps[key] !== oldProps[key]) return true;
|
|
1282
|
-
}
|
|
1283
|
-
return false;
|
|
1284
|
-
}
|
|
1285
1274
|
function comparePropsWithCallbacks(oldProps, newProps, onDeleted, onAdded, onUpdated) {
|
|
1286
1275
|
for (const key in oldProps) if (!(key in newProps)) onDeleted(key, oldProps[key]);
|
|
1287
1276
|
for (const key in newProps) if (!(key in oldProps)) onAdded(key, newProps[key]);
|
|
@@ -1494,7 +1483,7 @@ var Component = class {
|
|
|
1494
1483
|
this.refEffects = /* @__PURE__ */ new Map();
|
|
1495
1484
|
this.listener = new Dep(() => {
|
|
1496
1485
|
this.markAsDirtied();
|
|
1497
|
-
}, "
|
|
1486
|
+
}, "sync");
|
|
1498
1487
|
}
|
|
1499
1488
|
markAsDirtied() {
|
|
1500
1489
|
this._dirty = true;
|
|
@@ -1530,6 +1519,7 @@ var Component = class {
|
|
|
1530
1519
|
const oldProps = this.rawProps;
|
|
1531
1520
|
this.rawProps = newProps;
|
|
1532
1521
|
const newRefs = newProps.ref;
|
|
1522
|
+
updateRefs(newRefs, this.instance, this.refEffects);
|
|
1533
1523
|
comparePropsWithCallbacks(oldProps, newProps, (key) => {
|
|
1534
1524
|
internalWrite(() => {
|
|
1535
1525
|
Reflect.deleteProperty(oldProps, key);
|
|
@@ -1543,7 +1533,6 @@ var Component = class {
|
|
|
1543
1533
|
this.props[key] = value;
|
|
1544
1534
|
});
|
|
1545
1535
|
});
|
|
1546
|
-
updateRefs(newRefs, this.instance, this.refEffects);
|
|
1547
1536
|
}
|
|
1548
1537
|
rerender() {
|
|
1549
1538
|
this.listener.destroy();
|
|
@@ -1961,7 +1950,7 @@ function createRenderer(component, nativeRenderer, namespace) {
|
|
|
1961
1950
|
namespace
|
|
1962
1951
|
}, {
|
|
1963
1952
|
isParent: true,
|
|
1964
|
-
container,
|
|
1953
|
+
anchorNode: container,
|
|
1965
1954
|
rootContainer: container
|
|
1966
1955
|
});
|
|
1967
1956
|
} else deepUpdateByComponentDirtyTree(nativeRenderer, component, false);
|
|
@@ -1984,14 +1973,14 @@ function buildElementChildren(atom, nativeRenderer, parentComponent, context) {
|
|
|
1984
1973
|
}
|
|
1985
1974
|
}
|
|
1986
1975
|
function patchComponent(nativeRenderer, component, oldChildAtom, newAtom, context, needMove) {
|
|
1987
|
-
const oldContainer = component.viewMetadata.
|
|
1976
|
+
const oldContainer = component.viewMetadata.anchorNode;
|
|
1988
1977
|
const expectContainer = component.viewMetadata.expectContainer;
|
|
1989
1978
|
const newTemplate = component.rerender();
|
|
1990
1979
|
const portalContainer = getContainer();
|
|
1991
1980
|
popContainer();
|
|
1992
1981
|
if (portalContainer && portalContainer !== expectContainer) context = {
|
|
1993
1982
|
isParent: true,
|
|
1994
|
-
|
|
1983
|
+
anchorNode: portalContainer,
|
|
1995
1984
|
rootContainer: portalContainer
|
|
1996
1985
|
};
|
|
1997
1986
|
component.viewMetadata = {
|
|
@@ -1999,16 +1988,16 @@ function patchComponent(nativeRenderer, component, oldChildAtom, newAtom, contex
|
|
|
1999
1988
|
expectContainer,
|
|
2000
1989
|
...context
|
|
2001
1990
|
};
|
|
2002
|
-
if (oldContainer !== context.
|
|
1991
|
+
if (oldContainer !== context.anchorNode) needMove = true;
|
|
2003
1992
|
newAtom.child = createChildChain(newTemplate, nativeRenderer, newAtom.namespace);
|
|
2004
1993
|
diff(nativeRenderer, component, newAtom.child, oldChildAtom, context, needMove);
|
|
2005
1994
|
return context;
|
|
2006
1995
|
}
|
|
2007
1996
|
function deepUpdateByComponentDirtyTree(nativeRenderer, component, needMove) {
|
|
2008
1997
|
if (component.dirty) {
|
|
2009
|
-
const { atom,
|
|
1998
|
+
const { atom, anchorNode, isParent, rootContainer } = component.viewMetadata;
|
|
2010
1999
|
const context = {
|
|
2011
|
-
|
|
2000
|
+
anchorNode,
|
|
2012
2001
|
isParent,
|
|
2013
2002
|
rootContainer
|
|
2014
2003
|
};
|
|
@@ -2017,7 +2006,7 @@ function deepUpdateByComponentDirtyTree(nativeRenderer, component, needMove) {
|
|
|
2017
2006
|
const next = atom.sibling;
|
|
2018
2007
|
if (next && next.jsxNode instanceof Component) {
|
|
2019
2008
|
const view = next.jsxNode.viewMetadata;
|
|
2020
|
-
view.
|
|
2009
|
+
view.anchorNode = context.anchorNode;
|
|
2021
2010
|
view.isParent = context.isParent;
|
|
2022
2011
|
}
|
|
2023
2012
|
component.rendered();
|
|
@@ -2095,17 +2084,17 @@ function updateText(nativeRenderer, context, offset, needMove, newAtom, oldAtom)
|
|
|
2095
2084
|
const nativeNode = oldAtom.nativeNode;
|
|
2096
2085
|
newAtom.nativeNode = nativeNode;
|
|
2097
2086
|
if (needMove || newAtom.index - offset !== oldAtom.index) insertNode(nativeRenderer, newAtom, context);
|
|
2098
|
-
context.
|
|
2087
|
+
context.anchorNode = nativeNode;
|
|
2099
2088
|
context.isParent = false;
|
|
2100
2089
|
}
|
|
2101
2090
|
function updateElement(nativeRenderer, context, parentComponent, offset, needMove, newAtom, oldAtom) {
|
|
2102
2091
|
const nativeNode = oldAtom.nativeNode;
|
|
2103
2092
|
newAtom.nativeNode = nativeNode;
|
|
2104
2093
|
if (needMove || newAtom.index - offset !== oldAtom.index) insertNode(nativeRenderer, newAtom, context);
|
|
2105
|
-
context.
|
|
2094
|
+
context.anchorNode = nativeNode;
|
|
2106
2095
|
context.isParent = false;
|
|
2107
2096
|
updateNativeNodeProperties(nativeRenderer, newAtom, oldAtom, parentComponent, {
|
|
2108
|
-
|
|
2097
|
+
anchorNode: nativeNode,
|
|
2109
2098
|
isParent: true,
|
|
2110
2099
|
rootContainer: context.rootContainer
|
|
2111
2100
|
});
|
|
@@ -2115,14 +2104,13 @@ function updateComponent(nativeRenderer, context, offset, needMove, newAtom, old
|
|
|
2115
2104
|
const newProps = newAtom.jsxNode.props;
|
|
2116
2105
|
newAtom.jsxNode = component;
|
|
2117
2106
|
needMove = needMove || newAtom.index - offset !== oldAtom.index;
|
|
2118
|
-
|
|
2119
|
-
if (
|
|
2120
|
-
if (propsIsChanged || component.dirty) {
|
|
2107
|
+
component.updateProps(newProps);
|
|
2108
|
+
if (component.dirty) {
|
|
2121
2109
|
const updatedContext = patchComponent(nativeRenderer, component, oldAtom.child, newAtom, context, needMove);
|
|
2122
2110
|
const next = oldAtom.sibling;
|
|
2123
2111
|
if (next && next.jsxNode instanceof Component) {
|
|
2124
2112
|
const view = next.jsxNode.viewMetadata;
|
|
2125
|
-
view.
|
|
2113
|
+
view.anchorNode = updatedContext.anchorNode;
|
|
2126
2114
|
view.isParent = updatedContext.isParent;
|
|
2127
2115
|
}
|
|
2128
2116
|
} else {
|
|
@@ -2146,7 +2134,7 @@ function reuseComponentView(nativeRenderer, child, context, moveView, skipSubCom
|
|
|
2146
2134
|
if (moveView) insertNode(nativeRenderer, atom, context);
|
|
2147
2135
|
if (!skipSubComponentDiff) reuseElementChildrenView(nativeRenderer, atom, context);
|
|
2148
2136
|
context.isParent = false;
|
|
2149
|
-
context.
|
|
2137
|
+
context.anchorNode = atom.nativeNode;
|
|
2150
2138
|
}
|
|
2151
2139
|
};
|
|
2152
2140
|
while (child) {
|
|
@@ -2173,7 +2161,7 @@ function cleanElementChildren(atom, nativeRenderer) {
|
|
|
2173
2161
|
function cleanView(nativeRenderer, atom, needClean) {
|
|
2174
2162
|
if (atom.type === ComponentAtomType) {
|
|
2175
2163
|
const jsxNode = atom.jsxNode;
|
|
2176
|
-
if (jsxNode.viewMetadata.
|
|
2164
|
+
if (jsxNode.viewMetadata.anchorNode !== jsxNode.viewMetadata.expectContainer) needClean = true;
|
|
2177
2165
|
cleanChildren(atom, nativeRenderer, needClean);
|
|
2178
2166
|
jsxNode.destroy();
|
|
2179
2167
|
return;
|
|
@@ -2205,10 +2193,10 @@ function componentRender(nativeRenderer, component, from, context) {
|
|
|
2205
2193
|
const portalContainer = getContainer();
|
|
2206
2194
|
popContainer();
|
|
2207
2195
|
from.child = createChildChain(template, nativeRenderer, from.namespace);
|
|
2208
|
-
const expectContainer = context.
|
|
2209
|
-
context = portalContainer && portalContainer !== context.
|
|
2196
|
+
const expectContainer = context.anchorNode;
|
|
2197
|
+
context = portalContainer && portalContainer !== context.anchorNode ? {
|
|
2210
2198
|
isParent: true,
|
|
2211
|
-
|
|
2199
|
+
anchorNode: portalContainer,
|
|
2212
2200
|
rootContainer: portalContainer
|
|
2213
2201
|
} : context;
|
|
2214
2202
|
component.viewMetadata = {
|
|
@@ -2270,9 +2258,9 @@ function createChildChain(template, nativeRenderer, namespace) {
|
|
|
2270
2258
|
return beforeAtom.sibling;
|
|
2271
2259
|
}
|
|
2272
2260
|
function insertNode(nativeRenderer, atom, context) {
|
|
2273
|
-
if (context.isParent) if (context.
|
|
2274
|
-
else nativeRenderer.prependChild(context.
|
|
2275
|
-
else nativeRenderer.insertAfter(atom.nativeNode, context.
|
|
2261
|
+
if (context.isParent) if (context.anchorNode === context.rootContainer) nativeRenderer.appendChild(context.anchorNode, atom.nativeNode, atom.namespace);
|
|
2262
|
+
else nativeRenderer.prependChild(context.anchorNode, atom.nativeNode, atom.namespace);
|
|
2263
|
+
else nativeRenderer.insertAfter(atom.nativeNode, context.anchorNode, atom.namespace);
|
|
2276
2264
|
}
|
|
2277
2265
|
function createElementChildren(type, children, nativeRenderer, namespace) {
|
|
2278
2266
|
return createChildChain(children, nativeRenderer, nativeRenderer.getNameSpace(type, namespace));
|
|
@@ -2312,10 +2300,10 @@ function createElement(nativeRenderer, atom, parentComponent, context) {
|
|
|
2312
2300
|
insertNode(nativeRenderer, atom, context);
|
|
2313
2301
|
buildElementChildren(atom, nativeRenderer, parentComponent, {
|
|
2314
2302
|
isParent: true,
|
|
2315
|
-
|
|
2303
|
+
anchorNode: nativeNode,
|
|
2316
2304
|
rootContainer: context.rootContainer
|
|
2317
2305
|
});
|
|
2318
|
-
context.
|
|
2306
|
+
context.anchorNode = nativeNode;
|
|
2319
2307
|
context.isParent = false;
|
|
2320
2308
|
if (bindingRefs) {
|
|
2321
2309
|
const refEffects = /* @__PURE__ */ new Map();
|
|
@@ -2327,7 +2315,7 @@ function createTextNode(nativeRenderer, atom, context) {
|
|
|
2327
2315
|
const nativeNode = nativeRenderer.createTextNode(atom.jsxNode, atom.namespace);
|
|
2328
2316
|
atom.nativeNode = nativeNode;
|
|
2329
2317
|
insertNode(nativeRenderer, atom, context);
|
|
2330
|
-
context.
|
|
2318
|
+
context.anchorNode = nativeNode;
|
|
2331
2319
|
context.isParent = false;
|
|
2332
2320
|
}
|
|
2333
2321
|
function updateNativeNodeProperties(nativeRenderer, newAtom, oldAtom, parentComponent, context) {
|
|
@@ -2336,6 +2324,11 @@ function updateNativeNodeProperties(nativeRenderer, newAtom, oldAtom, parentComp
|
|
|
2336
2324
|
const nativeNode = newAtom.nativeNode;
|
|
2337
2325
|
const oldVNode = oldAtom.jsxNode;
|
|
2338
2326
|
if (newVNode === oldVNode) {
|
|
2327
|
+
const refEffects = nativeNodeRefRecord.get(oldAtom);
|
|
2328
|
+
if (refEffects) {
|
|
2329
|
+
nativeNodeRefRecord.delete(oldAtom);
|
|
2330
|
+
nativeNodeRefRecord.set(newAtom, refEffects);
|
|
2331
|
+
}
|
|
2339
2332
|
newAtom.child = oldAtom.child;
|
|
2340
2333
|
reuseElementChildrenView(nativeRenderer, newAtom, context);
|
|
2341
2334
|
return;
|
package/dist/index.js
CHANGED
|
@@ -1272,17 +1272,6 @@ function reactive(raw) {
|
|
|
1272
1272
|
}
|
|
1273
1273
|
//#endregion
|
|
1274
1274
|
//#region src/base/_utils.ts
|
|
1275
|
-
function hasChange(newProps, oldProps) {
|
|
1276
|
-
const newKeys = Object.keys(oldProps);
|
|
1277
|
-
const oldKeys = Object.keys(newProps);
|
|
1278
|
-
if (oldKeys.length !== newKeys.length) return true;
|
|
1279
|
-
const len = oldKeys.length;
|
|
1280
|
-
for (let i = 0; i < len; i++) {
|
|
1281
|
-
const key = newKeys[i];
|
|
1282
|
-
if (newProps[key] !== oldProps[key]) return true;
|
|
1283
|
-
}
|
|
1284
|
-
return false;
|
|
1285
|
-
}
|
|
1286
1275
|
function comparePropsWithCallbacks(oldProps, newProps, onDeleted, onAdded, onUpdated) {
|
|
1287
1276
|
for (const key in oldProps) if (!(key in newProps)) onDeleted(key, oldProps[key]);
|
|
1288
1277
|
for (const key in newProps) if (!(key in oldProps)) onAdded(key, newProps[key]);
|
|
@@ -1495,7 +1484,7 @@ var Component = class {
|
|
|
1495
1484
|
this.refEffects = /* @__PURE__ */ new Map();
|
|
1496
1485
|
this.listener = new Dep(() => {
|
|
1497
1486
|
this.markAsDirtied();
|
|
1498
|
-
}, "
|
|
1487
|
+
}, "sync");
|
|
1499
1488
|
}
|
|
1500
1489
|
markAsDirtied() {
|
|
1501
1490
|
this._dirty = true;
|
|
@@ -1531,6 +1520,7 @@ var Component = class {
|
|
|
1531
1520
|
const oldProps = this.rawProps;
|
|
1532
1521
|
this.rawProps = newProps;
|
|
1533
1522
|
const newRefs = newProps.ref;
|
|
1523
|
+
updateRefs(newRefs, this.instance, this.refEffects);
|
|
1534
1524
|
comparePropsWithCallbacks(oldProps, newProps, (key) => {
|
|
1535
1525
|
internalWrite(() => {
|
|
1536
1526
|
Reflect.deleteProperty(oldProps, key);
|
|
@@ -1544,7 +1534,6 @@ var Component = class {
|
|
|
1544
1534
|
this.props[key] = value;
|
|
1545
1535
|
});
|
|
1546
1536
|
});
|
|
1547
|
-
updateRefs(newRefs, this.instance, this.refEffects);
|
|
1548
1537
|
}
|
|
1549
1538
|
rerender() {
|
|
1550
1539
|
this.listener.destroy();
|
|
@@ -1962,7 +1951,7 @@ function createRenderer(component, nativeRenderer, namespace) {
|
|
|
1962
1951
|
namespace
|
|
1963
1952
|
}, {
|
|
1964
1953
|
isParent: true,
|
|
1965
|
-
container,
|
|
1954
|
+
anchorNode: container,
|
|
1966
1955
|
rootContainer: container
|
|
1967
1956
|
});
|
|
1968
1957
|
} else deepUpdateByComponentDirtyTree(nativeRenderer, component, false);
|
|
@@ -1985,14 +1974,14 @@ function buildElementChildren(atom, nativeRenderer, parentComponent, context) {
|
|
|
1985
1974
|
}
|
|
1986
1975
|
}
|
|
1987
1976
|
function patchComponent(nativeRenderer, component, oldChildAtom, newAtom, context, needMove) {
|
|
1988
|
-
const oldContainer = component.viewMetadata.
|
|
1977
|
+
const oldContainer = component.viewMetadata.anchorNode;
|
|
1989
1978
|
const expectContainer = component.viewMetadata.expectContainer;
|
|
1990
1979
|
const newTemplate = component.rerender();
|
|
1991
1980
|
const portalContainer = getContainer();
|
|
1992
1981
|
popContainer();
|
|
1993
1982
|
if (portalContainer && portalContainer !== expectContainer) context = {
|
|
1994
1983
|
isParent: true,
|
|
1995
|
-
|
|
1984
|
+
anchorNode: portalContainer,
|
|
1996
1985
|
rootContainer: portalContainer
|
|
1997
1986
|
};
|
|
1998
1987
|
component.viewMetadata = {
|
|
@@ -2000,16 +1989,16 @@ function patchComponent(nativeRenderer, component, oldChildAtom, newAtom, contex
|
|
|
2000
1989
|
expectContainer,
|
|
2001
1990
|
...context
|
|
2002
1991
|
};
|
|
2003
|
-
if (oldContainer !== context.
|
|
1992
|
+
if (oldContainer !== context.anchorNode) needMove = true;
|
|
2004
1993
|
newAtom.child = createChildChain(newTemplate, nativeRenderer, newAtom.namespace);
|
|
2005
1994
|
diff(nativeRenderer, component, newAtom.child, oldChildAtom, context, needMove);
|
|
2006
1995
|
return context;
|
|
2007
1996
|
}
|
|
2008
1997
|
function deepUpdateByComponentDirtyTree(nativeRenderer, component, needMove) {
|
|
2009
1998
|
if (component.dirty) {
|
|
2010
|
-
const { atom,
|
|
1999
|
+
const { atom, anchorNode, isParent, rootContainer } = component.viewMetadata;
|
|
2011
2000
|
const context = {
|
|
2012
|
-
|
|
2001
|
+
anchorNode,
|
|
2013
2002
|
isParent,
|
|
2014
2003
|
rootContainer
|
|
2015
2004
|
};
|
|
@@ -2018,7 +2007,7 @@ function deepUpdateByComponentDirtyTree(nativeRenderer, component, needMove) {
|
|
|
2018
2007
|
const next = atom.sibling;
|
|
2019
2008
|
if (next && next.jsxNode instanceof Component) {
|
|
2020
2009
|
const view = next.jsxNode.viewMetadata;
|
|
2021
|
-
view.
|
|
2010
|
+
view.anchorNode = context.anchorNode;
|
|
2022
2011
|
view.isParent = context.isParent;
|
|
2023
2012
|
}
|
|
2024
2013
|
component.rendered();
|
|
@@ -2096,17 +2085,17 @@ function updateText(nativeRenderer, context, offset, needMove, newAtom, oldAtom)
|
|
|
2096
2085
|
const nativeNode = oldAtom.nativeNode;
|
|
2097
2086
|
newAtom.nativeNode = nativeNode;
|
|
2098
2087
|
if (needMove || newAtom.index - offset !== oldAtom.index) insertNode(nativeRenderer, newAtom, context);
|
|
2099
|
-
context.
|
|
2088
|
+
context.anchorNode = nativeNode;
|
|
2100
2089
|
context.isParent = false;
|
|
2101
2090
|
}
|
|
2102
2091
|
function updateElement(nativeRenderer, context, parentComponent, offset, needMove, newAtom, oldAtom) {
|
|
2103
2092
|
const nativeNode = oldAtom.nativeNode;
|
|
2104
2093
|
newAtom.nativeNode = nativeNode;
|
|
2105
2094
|
if (needMove || newAtom.index - offset !== oldAtom.index) insertNode(nativeRenderer, newAtom, context);
|
|
2106
|
-
context.
|
|
2095
|
+
context.anchorNode = nativeNode;
|
|
2107
2096
|
context.isParent = false;
|
|
2108
2097
|
updateNativeNodeProperties(nativeRenderer, newAtom, oldAtom, parentComponent, {
|
|
2109
|
-
|
|
2098
|
+
anchorNode: nativeNode,
|
|
2110
2099
|
isParent: true,
|
|
2111
2100
|
rootContainer: context.rootContainer
|
|
2112
2101
|
});
|
|
@@ -2116,14 +2105,13 @@ function updateComponent(nativeRenderer, context, offset, needMove, newAtom, old
|
|
|
2116
2105
|
const newProps = newAtom.jsxNode.props;
|
|
2117
2106
|
newAtom.jsxNode = component;
|
|
2118
2107
|
needMove = needMove || newAtom.index - offset !== oldAtom.index;
|
|
2119
|
-
|
|
2120
|
-
if (
|
|
2121
|
-
if (propsIsChanged || component.dirty) {
|
|
2108
|
+
component.updateProps(newProps);
|
|
2109
|
+
if (component.dirty) {
|
|
2122
2110
|
const updatedContext = patchComponent(nativeRenderer, component, oldAtom.child, newAtom, context, needMove);
|
|
2123
2111
|
const next = oldAtom.sibling;
|
|
2124
2112
|
if (next && next.jsxNode instanceof Component) {
|
|
2125
2113
|
const view = next.jsxNode.viewMetadata;
|
|
2126
|
-
view.
|
|
2114
|
+
view.anchorNode = updatedContext.anchorNode;
|
|
2127
2115
|
view.isParent = updatedContext.isParent;
|
|
2128
2116
|
}
|
|
2129
2117
|
} else {
|
|
@@ -2147,7 +2135,7 @@ function reuseComponentView(nativeRenderer, child, context, moveView, skipSubCom
|
|
|
2147
2135
|
if (moveView) insertNode(nativeRenderer, atom, context);
|
|
2148
2136
|
if (!skipSubComponentDiff) reuseElementChildrenView(nativeRenderer, atom, context);
|
|
2149
2137
|
context.isParent = false;
|
|
2150
|
-
context.
|
|
2138
|
+
context.anchorNode = atom.nativeNode;
|
|
2151
2139
|
}
|
|
2152
2140
|
};
|
|
2153
2141
|
while (child) {
|
|
@@ -2174,7 +2162,7 @@ function cleanElementChildren(atom, nativeRenderer) {
|
|
|
2174
2162
|
function cleanView(nativeRenderer, atom, needClean) {
|
|
2175
2163
|
if (atom.type === ComponentAtomType) {
|
|
2176
2164
|
const jsxNode = atom.jsxNode;
|
|
2177
|
-
if (jsxNode.viewMetadata.
|
|
2165
|
+
if (jsxNode.viewMetadata.anchorNode !== jsxNode.viewMetadata.expectContainer) needClean = true;
|
|
2178
2166
|
cleanChildren(atom, nativeRenderer, needClean);
|
|
2179
2167
|
jsxNode.destroy();
|
|
2180
2168
|
return;
|
|
@@ -2206,10 +2194,10 @@ function componentRender(nativeRenderer, component, from, context) {
|
|
|
2206
2194
|
const portalContainer = getContainer();
|
|
2207
2195
|
popContainer();
|
|
2208
2196
|
from.child = createChildChain(template, nativeRenderer, from.namespace);
|
|
2209
|
-
const expectContainer = context.
|
|
2210
|
-
context = portalContainer && portalContainer !== context.
|
|
2197
|
+
const expectContainer = context.anchorNode;
|
|
2198
|
+
context = portalContainer && portalContainer !== context.anchorNode ? {
|
|
2211
2199
|
isParent: true,
|
|
2212
|
-
|
|
2200
|
+
anchorNode: portalContainer,
|
|
2213
2201
|
rootContainer: portalContainer
|
|
2214
2202
|
} : context;
|
|
2215
2203
|
component.viewMetadata = {
|
|
@@ -2271,9 +2259,9 @@ function createChildChain(template, nativeRenderer, namespace) {
|
|
|
2271
2259
|
return beforeAtom.sibling;
|
|
2272
2260
|
}
|
|
2273
2261
|
function insertNode(nativeRenderer, atom, context) {
|
|
2274
|
-
if (context.isParent) if (context.
|
|
2275
|
-
else nativeRenderer.prependChild(context.
|
|
2276
|
-
else nativeRenderer.insertAfter(atom.nativeNode, context.
|
|
2262
|
+
if (context.isParent) if (context.anchorNode === context.rootContainer) nativeRenderer.appendChild(context.anchorNode, atom.nativeNode, atom.namespace);
|
|
2263
|
+
else nativeRenderer.prependChild(context.anchorNode, atom.nativeNode, atom.namespace);
|
|
2264
|
+
else nativeRenderer.insertAfter(atom.nativeNode, context.anchorNode, atom.namespace);
|
|
2277
2265
|
}
|
|
2278
2266
|
function createElementChildren(type, children, nativeRenderer, namespace) {
|
|
2279
2267
|
return createChildChain(children, nativeRenderer, nativeRenderer.getNameSpace(type, namespace));
|
|
@@ -2313,10 +2301,10 @@ function createElement(nativeRenderer, atom, parentComponent, context) {
|
|
|
2313
2301
|
insertNode(nativeRenderer, atom, context);
|
|
2314
2302
|
buildElementChildren(atom, nativeRenderer, parentComponent, {
|
|
2315
2303
|
isParent: true,
|
|
2316
|
-
|
|
2304
|
+
anchorNode: nativeNode,
|
|
2317
2305
|
rootContainer: context.rootContainer
|
|
2318
2306
|
});
|
|
2319
|
-
context.
|
|
2307
|
+
context.anchorNode = nativeNode;
|
|
2320
2308
|
context.isParent = false;
|
|
2321
2309
|
if (bindingRefs) {
|
|
2322
2310
|
const refEffects = /* @__PURE__ */ new Map();
|
|
@@ -2328,7 +2316,7 @@ function createTextNode(nativeRenderer, atom, context) {
|
|
|
2328
2316
|
const nativeNode = nativeRenderer.createTextNode(atom.jsxNode, atom.namespace);
|
|
2329
2317
|
atom.nativeNode = nativeNode;
|
|
2330
2318
|
insertNode(nativeRenderer, atom, context);
|
|
2331
|
-
context.
|
|
2319
|
+
context.anchorNode = nativeNode;
|
|
2332
2320
|
context.isParent = false;
|
|
2333
2321
|
}
|
|
2334
2322
|
function updateNativeNodeProperties(nativeRenderer, newAtom, oldAtom, parentComponent, context) {
|
|
@@ -2337,6 +2325,11 @@ function updateNativeNodeProperties(nativeRenderer, newAtom, oldAtom, parentComp
|
|
|
2337
2325
|
const nativeNode = newAtom.nativeNode;
|
|
2338
2326
|
const oldVNode = oldAtom.jsxNode;
|
|
2339
2327
|
if (newVNode === oldVNode) {
|
|
2328
|
+
const refEffects = nativeNodeRefRecord.get(oldAtom);
|
|
2329
|
+
if (refEffects) {
|
|
2330
|
+
nativeNodeRefRecord.delete(oldAtom);
|
|
2331
|
+
nativeNodeRefRecord.set(newAtom, refEffects);
|
|
2332
|
+
}
|
|
2340
2333
|
newAtom.child = oldAtom.child;
|
|
2341
2334
|
reuseElementChildrenView(nativeRenderer, newAtom, context);
|
|
2342
2335
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viewfly/core",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.4",
|
|
4
4
|
"description": "Viewfly is a simple and easy-to-use JavaScript framework with an intuitive development experience.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.esm.js",
|