@viewfly/core 1.0.0-alpha.11 → 1.0.0-alpha.12
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/bundles/index.esm.js +78 -78
- package/bundles/index.js +78 -78
- package/package.json +2 -2
package/bundles/index.esm.js
CHANGED
|
@@ -1284,7 +1284,7 @@ function withMemo(canUseMemo, render) {
|
|
|
1284
1284
|
}
|
|
1285
1285
|
|
|
1286
1286
|
const componentViewCache = new WeakMap();
|
|
1287
|
-
const listenerReg = /^on
|
|
1287
|
+
const listenerReg = /^on[A-Z]/;
|
|
1288
1288
|
function createRenderer(component, nativeRenderer) {
|
|
1289
1289
|
let isInit = true;
|
|
1290
1290
|
return function render(host) {
|
|
@@ -1317,36 +1317,23 @@ function buildView(nativeRenderer, parentComponent, atom, context) {
|
|
|
1317
1317
|
atom.jsxNode = component;
|
|
1318
1318
|
componentRender(nativeRenderer, component, atom, context);
|
|
1319
1319
|
}
|
|
1320
|
+
else if (type === 'element') {
|
|
1321
|
+
createElement(nativeRenderer, atom, parentComponent, context);
|
|
1322
|
+
}
|
|
1320
1323
|
else {
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
const childContext = {
|
|
1335
|
-
isParent: true,
|
|
1336
|
-
host: nativeNode,
|
|
1337
|
-
rootHost: context.rootHost
|
|
1338
|
-
};
|
|
1339
|
-
let child = atom.child;
|
|
1340
|
-
while (child) {
|
|
1341
|
-
buildView(nativeRenderer, parentComponent, child, childContext);
|
|
1342
|
-
child = child.sibling;
|
|
1343
|
-
}
|
|
1344
|
-
}
|
|
1345
|
-
context.host = nativeNode;
|
|
1346
|
-
context.isParent = false;
|
|
1347
|
-
if (applyRefs) {
|
|
1348
|
-
applyRefs();
|
|
1349
|
-
}
|
|
1324
|
+
createTextNode(nativeRenderer, atom, context);
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
function buildElementChildren(atom, nativeRenderer, parentComponent, context) {
|
|
1328
|
+
const childContext = {
|
|
1329
|
+
isParent: true,
|
|
1330
|
+
host: atom.nativeNode,
|
|
1331
|
+
rootHost: context.rootHost
|
|
1332
|
+
};
|
|
1333
|
+
let child = atom.child;
|
|
1334
|
+
while (child) {
|
|
1335
|
+
buildView(nativeRenderer, parentComponent, child, childContext);
|
|
1336
|
+
child = child.sibling;
|
|
1350
1337
|
}
|
|
1351
1338
|
}
|
|
1352
1339
|
function updateView(nativeRenderer, component) {
|
|
@@ -1472,23 +1459,7 @@ function updateElement(newAtom, oldAtom, expectIndex, oldIndex, nativeRenderer,
|
|
|
1472
1459
|
}
|
|
1473
1460
|
context.host = newAtom.nativeNode;
|
|
1474
1461
|
context.isParent = false;
|
|
1475
|
-
|
|
1476
|
-
if (newAtom.child) {
|
|
1477
|
-
diff(nativeRenderer, parentComponent, newAtom.child, oldAtom.child, {
|
|
1478
|
-
host: newAtom.nativeNode,
|
|
1479
|
-
isParent: true,
|
|
1480
|
-
rootHost: context.rootHost
|
|
1481
|
-
});
|
|
1482
|
-
}
|
|
1483
|
-
else if (oldAtom.child) {
|
|
1484
|
-
let atom = oldAtom.child;
|
|
1485
|
-
nativeRenderer.cleanChildren(oldAtom.nativeNode, oldAtom.isSvg);
|
|
1486
|
-
while (atom) {
|
|
1487
|
-
cleanView(nativeRenderer, atom, false);
|
|
1488
|
-
atom = atom.sibling;
|
|
1489
|
-
}
|
|
1490
|
-
}
|
|
1491
|
-
applyRefs();
|
|
1462
|
+
updateNativeNodeProperties(nativeRenderer, newAtom, oldAtom, parentComponent, context);
|
|
1492
1463
|
};
|
|
1493
1464
|
}
|
|
1494
1465
|
function updateComponent(newAtom, reusedAtom, expectIndex, oldIndex, nativeRenderer, context) {
|
|
@@ -1546,6 +1517,14 @@ function reuseComponentView(nativeRenderer, newAtom, reusedAtom, context, moveVi
|
|
|
1546
1517
|
child = child.sibling;
|
|
1547
1518
|
}
|
|
1548
1519
|
}
|
|
1520
|
+
function cleanElementChildren(atom, nativeRenderer) {
|
|
1521
|
+
let child = atom.child;
|
|
1522
|
+
nativeRenderer.cleanChildren(atom.nativeNode, atom.isSvg);
|
|
1523
|
+
while (child) {
|
|
1524
|
+
cleanView(nativeRenderer, child, false);
|
|
1525
|
+
child = child.sibling;
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1549
1528
|
function cleanView(nativeRenderer, atom, needClean) {
|
|
1550
1529
|
if (atom.nativeNode) {
|
|
1551
1530
|
if (needClean) {
|
|
@@ -1619,7 +1598,6 @@ function createChainByJSXElement(element, prevAtom, isSvg) {
|
|
|
1619
1598
|
isSvg
|
|
1620
1599
|
};
|
|
1621
1600
|
prevAtom.sibling = atom;
|
|
1622
|
-
atom.child = createChildChain(element.props.children, isSvg);
|
|
1623
1601
|
return atom;
|
|
1624
1602
|
}
|
|
1625
1603
|
function createChainByNode(jsxNode, prevAtom, isSvg) {
|
|
@@ -1668,12 +1646,14 @@ function insertNode(nativeRenderer, atom, context) {
|
|
|
1668
1646
|
nativeRenderer.insertAfter(atom.nativeNode, context.host, atom.isSvg);
|
|
1669
1647
|
}
|
|
1670
1648
|
}
|
|
1671
|
-
function createElement(nativeRenderer,
|
|
1672
|
-
const
|
|
1673
|
-
const
|
|
1649
|
+
function createElement(nativeRenderer, atom, parentComponent, context) {
|
|
1650
|
+
const { isSvg, jsxNode } = atom;
|
|
1651
|
+
const nativeNode = nativeRenderer.createElement(jsxNode.type, isSvg);
|
|
1652
|
+
const props = jsxNode.props;
|
|
1674
1653
|
let bindingRefs;
|
|
1675
1654
|
for (const key in props) {
|
|
1676
1655
|
if (key === 'children') {
|
|
1656
|
+
atom.child = createChildChain(jsxNode.props.children, isSvg);
|
|
1677
1657
|
continue;
|
|
1678
1658
|
}
|
|
1679
1659
|
if (key === 'class') {
|
|
@@ -1693,7 +1673,7 @@ function createElement(nativeRenderer, vNode, isSvg) {
|
|
|
1693
1673
|
if (listenerReg.test(key)) {
|
|
1694
1674
|
const listener = props[key];
|
|
1695
1675
|
if (typeof listener === 'function') {
|
|
1696
|
-
bindEvent(nativeRenderer,
|
|
1676
|
+
bindEvent(nativeRenderer, jsxNode, key, nativeNode, listener, isSvg);
|
|
1697
1677
|
}
|
|
1698
1678
|
continue;
|
|
1699
1679
|
}
|
|
@@ -1703,28 +1683,40 @@ function createElement(nativeRenderer, vNode, isSvg) {
|
|
|
1703
1683
|
}
|
|
1704
1684
|
nativeRenderer.setProperty(nativeNode, key, props[key], isSvg);
|
|
1705
1685
|
}
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
}
|
|
1713
|
-
function createTextNode(nativeRenderer,
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1686
|
+
atom.nativeNode = nativeNode;
|
|
1687
|
+
insertNode(nativeRenderer, atom, context);
|
|
1688
|
+
buildElementChildren(atom, nativeRenderer, parentComponent, context);
|
|
1689
|
+
context.host = nativeNode;
|
|
1690
|
+
context.isParent = false;
|
|
1691
|
+
applyRefs(bindingRefs, nativeNode, true);
|
|
1692
|
+
}
|
|
1693
|
+
function createTextNode(nativeRenderer, atom, context) {
|
|
1694
|
+
const nativeNode = nativeRenderer.createTextNode(atom.jsxNode, atom.isSvg);
|
|
1695
|
+
atom.nativeNode = nativeNode;
|
|
1696
|
+
insertNode(nativeRenderer, atom, context);
|
|
1697
|
+
context.host = nativeNode;
|
|
1698
|
+
context.isParent = false;
|
|
1699
|
+
}
|
|
1700
|
+
function updateNativeNodeProperties(nativeRenderer, newAtom, oldAtom, parentComponent, context) {
|
|
1701
|
+
const newVNode = newAtom.jsxNode;
|
|
1702
|
+
const isSvg = newAtom.isSvg;
|
|
1703
|
+
const nativeNode = newAtom.nativeNode;
|
|
1704
|
+
const oldVNode = oldAtom.jsxNode;
|
|
1717
1705
|
if (newVNode === oldVNode) {
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
};
|
|
1706
|
+
parentComponent.changedSubComponents.forEach(child => {
|
|
1707
|
+
updateView(nativeRenderer, child);
|
|
1708
|
+
});
|
|
1709
|
+
return;
|
|
1721
1710
|
}
|
|
1722
1711
|
const changes = getObjectChanges(newVNode.props, oldVNode.props);
|
|
1723
1712
|
let unBindRefs;
|
|
1724
1713
|
let bindRefs;
|
|
1725
1714
|
newVNode.on = oldVNode.on;
|
|
1715
|
+
newAtom.child = oldAtom.child;
|
|
1726
1716
|
for (const [key, value] of changes.remove) {
|
|
1727
1717
|
if (key === 'children') {
|
|
1718
|
+
cleanElementChildren(oldAtom, nativeRenderer);
|
|
1719
|
+
newAtom.child = null;
|
|
1728
1720
|
continue;
|
|
1729
1721
|
}
|
|
1730
1722
|
if (key === 'class') {
|
|
@@ -1739,10 +1731,9 @@ function updateNativeNodeProperties(nativeRenderer, newVNode, oldVNode, nativeNo
|
|
|
1739
1731
|
}
|
|
1740
1732
|
if (listenerReg.test(key)) {
|
|
1741
1733
|
if (typeof value === 'function') {
|
|
1742
|
-
const type = key.replace(listenerReg, '').toLowerCase();
|
|
1743
1734
|
const oldOn = oldVNode.on;
|
|
1744
|
-
nativeRenderer.unListen(nativeNode,
|
|
1745
|
-
Reflect.deleteProperty(oldOn,
|
|
1735
|
+
nativeRenderer.unListen(nativeNode, key, oldOn[key].delegate, isSvg);
|
|
1736
|
+
Reflect.deleteProperty(oldOn, key);
|
|
1746
1737
|
}
|
|
1747
1738
|
continue;
|
|
1748
1739
|
}
|
|
@@ -1754,6 +1745,17 @@ function updateNativeNodeProperties(nativeRenderer, newVNode, oldVNode, nativeNo
|
|
|
1754
1745
|
}
|
|
1755
1746
|
for (const [key, newValue, oldValue] of changes.replace) {
|
|
1756
1747
|
if (key === 'children') {
|
|
1748
|
+
newAtom.child = createChildChain(newValue, isSvg);
|
|
1749
|
+
if (!newAtom.child) {
|
|
1750
|
+
cleanElementChildren(oldAtom, nativeRenderer);
|
|
1751
|
+
}
|
|
1752
|
+
else {
|
|
1753
|
+
diff(nativeRenderer, parentComponent, newAtom.child, oldAtom.child, {
|
|
1754
|
+
host: newAtom.nativeNode,
|
|
1755
|
+
isParent: true,
|
|
1756
|
+
rootHost: context.rootHost
|
|
1757
|
+
});
|
|
1758
|
+
}
|
|
1757
1759
|
continue;
|
|
1758
1760
|
}
|
|
1759
1761
|
if (key === 'class') {
|
|
@@ -1775,8 +1777,7 @@ function updateNativeNodeProperties(nativeRenderer, newVNode, oldVNode, nativeNo
|
|
|
1775
1777
|
continue;
|
|
1776
1778
|
}
|
|
1777
1779
|
if (listenerReg.test(key)) {
|
|
1778
|
-
|
|
1779
|
-
newVNode.on[listenType].listenFn = newValue;
|
|
1780
|
+
newVNode.on[key].listenFn = newValue;
|
|
1780
1781
|
continue;
|
|
1781
1782
|
}
|
|
1782
1783
|
if (key === refKey) {
|
|
@@ -1788,6 +1789,8 @@ function updateNativeNodeProperties(nativeRenderer, newVNode, oldVNode, nativeNo
|
|
|
1788
1789
|
}
|
|
1789
1790
|
for (const [key, value] of changes.add) {
|
|
1790
1791
|
if (key === 'children') {
|
|
1792
|
+
newAtom.child = createChildChain(value, isSvg);
|
|
1793
|
+
buildElementChildren(newAtom, nativeRenderer, parentComponent, context);
|
|
1791
1794
|
continue;
|
|
1792
1795
|
}
|
|
1793
1796
|
if (key === 'class') {
|
|
@@ -1813,10 +1816,8 @@ function updateNativeNodeProperties(nativeRenderer, newVNode, oldVNode, nativeNo
|
|
|
1813
1816
|
}
|
|
1814
1817
|
nativeRenderer.setProperty(nativeNode, key, value, isSvg);
|
|
1815
1818
|
}
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
applyRefs(bindRefs, nativeNode, true);
|
|
1819
|
-
};
|
|
1819
|
+
applyRefs(unBindRefs, nativeNode, false);
|
|
1820
|
+
applyRefs(bindRefs, nativeNode, true);
|
|
1820
1821
|
}
|
|
1821
1822
|
function applyRefs(refs, nativeNode, binding) {
|
|
1822
1823
|
if (refs) {
|
|
@@ -1833,15 +1834,14 @@ function bindEvent(nativeRenderer, vNode, key, nativeNode, listenFn, isSvg) {
|
|
|
1833
1834
|
if (!on) {
|
|
1834
1835
|
vNode.on = on = {};
|
|
1835
1836
|
}
|
|
1836
|
-
const type = key.replace(listenerReg, '').toLowerCase();
|
|
1837
1837
|
const delegateObj = {
|
|
1838
1838
|
delegate(...args) {
|
|
1839
1839
|
return delegateObj.listenFn.apply(this, args);
|
|
1840
1840
|
},
|
|
1841
1841
|
listenFn
|
|
1842
1842
|
};
|
|
1843
|
-
on[
|
|
1844
|
-
nativeRenderer.listen(nativeNode,
|
|
1843
|
+
on[key] = delegateObj;
|
|
1844
|
+
nativeRenderer.listen(nativeNode, key, delegateObj.delegate, isSvg);
|
|
1845
1845
|
}
|
|
1846
1846
|
|
|
1847
1847
|
/**
|
package/bundles/index.js
CHANGED
|
@@ -1286,7 +1286,7 @@ function withMemo(canUseMemo, render) {
|
|
|
1286
1286
|
}
|
|
1287
1287
|
|
|
1288
1288
|
const componentViewCache = new WeakMap();
|
|
1289
|
-
const listenerReg = /^on
|
|
1289
|
+
const listenerReg = /^on[A-Z]/;
|
|
1290
1290
|
function createRenderer(component, nativeRenderer) {
|
|
1291
1291
|
let isInit = true;
|
|
1292
1292
|
return function render(host) {
|
|
@@ -1319,36 +1319,23 @@ function buildView(nativeRenderer, parentComponent, atom, context) {
|
|
|
1319
1319
|
atom.jsxNode = component;
|
|
1320
1320
|
componentRender(nativeRenderer, component, atom, context);
|
|
1321
1321
|
}
|
|
1322
|
+
else if (type === 'element') {
|
|
1323
|
+
createElement(nativeRenderer, atom, parentComponent, context);
|
|
1324
|
+
}
|
|
1322
1325
|
else {
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
const childContext = {
|
|
1337
|
-
isParent: true,
|
|
1338
|
-
host: nativeNode,
|
|
1339
|
-
rootHost: context.rootHost
|
|
1340
|
-
};
|
|
1341
|
-
let child = atom.child;
|
|
1342
|
-
while (child) {
|
|
1343
|
-
buildView(nativeRenderer, parentComponent, child, childContext);
|
|
1344
|
-
child = child.sibling;
|
|
1345
|
-
}
|
|
1346
|
-
}
|
|
1347
|
-
context.host = nativeNode;
|
|
1348
|
-
context.isParent = false;
|
|
1349
|
-
if (applyRefs) {
|
|
1350
|
-
applyRefs();
|
|
1351
|
-
}
|
|
1326
|
+
createTextNode(nativeRenderer, atom, context);
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
function buildElementChildren(atom, nativeRenderer, parentComponent, context) {
|
|
1330
|
+
const childContext = {
|
|
1331
|
+
isParent: true,
|
|
1332
|
+
host: atom.nativeNode,
|
|
1333
|
+
rootHost: context.rootHost
|
|
1334
|
+
};
|
|
1335
|
+
let child = atom.child;
|
|
1336
|
+
while (child) {
|
|
1337
|
+
buildView(nativeRenderer, parentComponent, child, childContext);
|
|
1338
|
+
child = child.sibling;
|
|
1352
1339
|
}
|
|
1353
1340
|
}
|
|
1354
1341
|
function updateView(nativeRenderer, component) {
|
|
@@ -1474,23 +1461,7 @@ function updateElement(newAtom, oldAtom, expectIndex, oldIndex, nativeRenderer,
|
|
|
1474
1461
|
}
|
|
1475
1462
|
context.host = newAtom.nativeNode;
|
|
1476
1463
|
context.isParent = false;
|
|
1477
|
-
|
|
1478
|
-
if (newAtom.child) {
|
|
1479
|
-
diff(nativeRenderer, parentComponent, newAtom.child, oldAtom.child, {
|
|
1480
|
-
host: newAtom.nativeNode,
|
|
1481
|
-
isParent: true,
|
|
1482
|
-
rootHost: context.rootHost
|
|
1483
|
-
});
|
|
1484
|
-
}
|
|
1485
|
-
else if (oldAtom.child) {
|
|
1486
|
-
let atom = oldAtom.child;
|
|
1487
|
-
nativeRenderer.cleanChildren(oldAtom.nativeNode, oldAtom.isSvg);
|
|
1488
|
-
while (atom) {
|
|
1489
|
-
cleanView(nativeRenderer, atom, false);
|
|
1490
|
-
atom = atom.sibling;
|
|
1491
|
-
}
|
|
1492
|
-
}
|
|
1493
|
-
applyRefs();
|
|
1464
|
+
updateNativeNodeProperties(nativeRenderer, newAtom, oldAtom, parentComponent, context);
|
|
1494
1465
|
};
|
|
1495
1466
|
}
|
|
1496
1467
|
function updateComponent(newAtom, reusedAtom, expectIndex, oldIndex, nativeRenderer, context) {
|
|
@@ -1548,6 +1519,14 @@ function reuseComponentView(nativeRenderer, newAtom, reusedAtom, context, moveVi
|
|
|
1548
1519
|
child = child.sibling;
|
|
1549
1520
|
}
|
|
1550
1521
|
}
|
|
1522
|
+
function cleanElementChildren(atom, nativeRenderer) {
|
|
1523
|
+
let child = atom.child;
|
|
1524
|
+
nativeRenderer.cleanChildren(atom.nativeNode, atom.isSvg);
|
|
1525
|
+
while (child) {
|
|
1526
|
+
cleanView(nativeRenderer, child, false);
|
|
1527
|
+
child = child.sibling;
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1551
1530
|
function cleanView(nativeRenderer, atom, needClean) {
|
|
1552
1531
|
if (atom.nativeNode) {
|
|
1553
1532
|
if (needClean) {
|
|
@@ -1621,7 +1600,6 @@ function createChainByJSXElement(element, prevAtom, isSvg) {
|
|
|
1621
1600
|
isSvg
|
|
1622
1601
|
};
|
|
1623
1602
|
prevAtom.sibling = atom;
|
|
1624
|
-
atom.child = createChildChain(element.props.children, isSvg);
|
|
1625
1603
|
return atom;
|
|
1626
1604
|
}
|
|
1627
1605
|
function createChainByNode(jsxNode, prevAtom, isSvg) {
|
|
@@ -1670,12 +1648,14 @@ function insertNode(nativeRenderer, atom, context) {
|
|
|
1670
1648
|
nativeRenderer.insertAfter(atom.nativeNode, context.host, atom.isSvg);
|
|
1671
1649
|
}
|
|
1672
1650
|
}
|
|
1673
|
-
function createElement(nativeRenderer,
|
|
1674
|
-
const
|
|
1675
|
-
const
|
|
1651
|
+
function createElement(nativeRenderer, atom, parentComponent, context) {
|
|
1652
|
+
const { isSvg, jsxNode } = atom;
|
|
1653
|
+
const nativeNode = nativeRenderer.createElement(jsxNode.type, isSvg);
|
|
1654
|
+
const props = jsxNode.props;
|
|
1676
1655
|
let bindingRefs;
|
|
1677
1656
|
for (const key in props) {
|
|
1678
1657
|
if (key === 'children') {
|
|
1658
|
+
atom.child = createChildChain(jsxNode.props.children, isSvg);
|
|
1679
1659
|
continue;
|
|
1680
1660
|
}
|
|
1681
1661
|
if (key === 'class') {
|
|
@@ -1695,7 +1675,7 @@ function createElement(nativeRenderer, vNode, isSvg) {
|
|
|
1695
1675
|
if (listenerReg.test(key)) {
|
|
1696
1676
|
const listener = props[key];
|
|
1697
1677
|
if (typeof listener === 'function') {
|
|
1698
|
-
bindEvent(nativeRenderer,
|
|
1678
|
+
bindEvent(nativeRenderer, jsxNode, key, nativeNode, listener, isSvg);
|
|
1699
1679
|
}
|
|
1700
1680
|
continue;
|
|
1701
1681
|
}
|
|
@@ -1705,28 +1685,40 @@ function createElement(nativeRenderer, vNode, isSvg) {
|
|
|
1705
1685
|
}
|
|
1706
1686
|
nativeRenderer.setProperty(nativeNode, key, props[key], isSvg);
|
|
1707
1687
|
}
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
}
|
|
1715
|
-
function createTextNode(nativeRenderer,
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1688
|
+
atom.nativeNode = nativeNode;
|
|
1689
|
+
insertNode(nativeRenderer, atom, context);
|
|
1690
|
+
buildElementChildren(atom, nativeRenderer, parentComponent, context);
|
|
1691
|
+
context.host = nativeNode;
|
|
1692
|
+
context.isParent = false;
|
|
1693
|
+
applyRefs(bindingRefs, nativeNode, true);
|
|
1694
|
+
}
|
|
1695
|
+
function createTextNode(nativeRenderer, atom, context) {
|
|
1696
|
+
const nativeNode = nativeRenderer.createTextNode(atom.jsxNode, atom.isSvg);
|
|
1697
|
+
atom.nativeNode = nativeNode;
|
|
1698
|
+
insertNode(nativeRenderer, atom, context);
|
|
1699
|
+
context.host = nativeNode;
|
|
1700
|
+
context.isParent = false;
|
|
1701
|
+
}
|
|
1702
|
+
function updateNativeNodeProperties(nativeRenderer, newAtom, oldAtom, parentComponent, context) {
|
|
1703
|
+
const newVNode = newAtom.jsxNode;
|
|
1704
|
+
const isSvg = newAtom.isSvg;
|
|
1705
|
+
const nativeNode = newAtom.nativeNode;
|
|
1706
|
+
const oldVNode = oldAtom.jsxNode;
|
|
1719
1707
|
if (newVNode === oldVNode) {
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
};
|
|
1708
|
+
parentComponent.changedSubComponents.forEach(child => {
|
|
1709
|
+
updateView(nativeRenderer, child);
|
|
1710
|
+
});
|
|
1711
|
+
return;
|
|
1723
1712
|
}
|
|
1724
1713
|
const changes = getObjectChanges(newVNode.props, oldVNode.props);
|
|
1725
1714
|
let unBindRefs;
|
|
1726
1715
|
let bindRefs;
|
|
1727
1716
|
newVNode.on = oldVNode.on;
|
|
1717
|
+
newAtom.child = oldAtom.child;
|
|
1728
1718
|
for (const [key, value] of changes.remove) {
|
|
1729
1719
|
if (key === 'children') {
|
|
1720
|
+
cleanElementChildren(oldAtom, nativeRenderer);
|
|
1721
|
+
newAtom.child = null;
|
|
1730
1722
|
continue;
|
|
1731
1723
|
}
|
|
1732
1724
|
if (key === 'class') {
|
|
@@ -1741,10 +1733,9 @@ function updateNativeNodeProperties(nativeRenderer, newVNode, oldVNode, nativeNo
|
|
|
1741
1733
|
}
|
|
1742
1734
|
if (listenerReg.test(key)) {
|
|
1743
1735
|
if (typeof value === 'function') {
|
|
1744
|
-
const type = key.replace(listenerReg, '').toLowerCase();
|
|
1745
1736
|
const oldOn = oldVNode.on;
|
|
1746
|
-
nativeRenderer.unListen(nativeNode,
|
|
1747
|
-
Reflect.deleteProperty(oldOn,
|
|
1737
|
+
nativeRenderer.unListen(nativeNode, key, oldOn[key].delegate, isSvg);
|
|
1738
|
+
Reflect.deleteProperty(oldOn, key);
|
|
1748
1739
|
}
|
|
1749
1740
|
continue;
|
|
1750
1741
|
}
|
|
@@ -1756,6 +1747,17 @@ function updateNativeNodeProperties(nativeRenderer, newVNode, oldVNode, nativeNo
|
|
|
1756
1747
|
}
|
|
1757
1748
|
for (const [key, newValue, oldValue] of changes.replace) {
|
|
1758
1749
|
if (key === 'children') {
|
|
1750
|
+
newAtom.child = createChildChain(newValue, isSvg);
|
|
1751
|
+
if (!newAtom.child) {
|
|
1752
|
+
cleanElementChildren(oldAtom, nativeRenderer);
|
|
1753
|
+
}
|
|
1754
|
+
else {
|
|
1755
|
+
diff(nativeRenderer, parentComponent, newAtom.child, oldAtom.child, {
|
|
1756
|
+
host: newAtom.nativeNode,
|
|
1757
|
+
isParent: true,
|
|
1758
|
+
rootHost: context.rootHost
|
|
1759
|
+
});
|
|
1760
|
+
}
|
|
1759
1761
|
continue;
|
|
1760
1762
|
}
|
|
1761
1763
|
if (key === 'class') {
|
|
@@ -1777,8 +1779,7 @@ function updateNativeNodeProperties(nativeRenderer, newVNode, oldVNode, nativeNo
|
|
|
1777
1779
|
continue;
|
|
1778
1780
|
}
|
|
1779
1781
|
if (listenerReg.test(key)) {
|
|
1780
|
-
|
|
1781
|
-
newVNode.on[listenType].listenFn = newValue;
|
|
1782
|
+
newVNode.on[key].listenFn = newValue;
|
|
1782
1783
|
continue;
|
|
1783
1784
|
}
|
|
1784
1785
|
if (key === refKey) {
|
|
@@ -1790,6 +1791,8 @@ function updateNativeNodeProperties(nativeRenderer, newVNode, oldVNode, nativeNo
|
|
|
1790
1791
|
}
|
|
1791
1792
|
for (const [key, value] of changes.add) {
|
|
1792
1793
|
if (key === 'children') {
|
|
1794
|
+
newAtom.child = createChildChain(value, isSvg);
|
|
1795
|
+
buildElementChildren(newAtom, nativeRenderer, parentComponent, context);
|
|
1793
1796
|
continue;
|
|
1794
1797
|
}
|
|
1795
1798
|
if (key === 'class') {
|
|
@@ -1815,10 +1818,8 @@ function updateNativeNodeProperties(nativeRenderer, newVNode, oldVNode, nativeNo
|
|
|
1815
1818
|
}
|
|
1816
1819
|
nativeRenderer.setProperty(nativeNode, key, value, isSvg);
|
|
1817
1820
|
}
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
applyRefs(bindRefs, nativeNode, true);
|
|
1821
|
-
};
|
|
1821
|
+
applyRefs(unBindRefs, nativeNode, false);
|
|
1822
|
+
applyRefs(bindRefs, nativeNode, true);
|
|
1822
1823
|
}
|
|
1823
1824
|
function applyRefs(refs, nativeNode, binding) {
|
|
1824
1825
|
if (refs) {
|
|
@@ -1835,15 +1836,14 @@ function bindEvent(nativeRenderer, vNode, key, nativeNode, listenFn, isSvg) {
|
|
|
1835
1836
|
if (!on) {
|
|
1836
1837
|
vNode.on = on = {};
|
|
1837
1838
|
}
|
|
1838
|
-
const type = key.replace(listenerReg, '').toLowerCase();
|
|
1839
1839
|
const delegateObj = {
|
|
1840
1840
|
delegate(...args) {
|
|
1841
1841
|
return delegateObj.listenFn.apply(this, args);
|
|
1842
1842
|
},
|
|
1843
1843
|
listenFn
|
|
1844
1844
|
};
|
|
1845
|
-
on[
|
|
1846
|
-
nativeRenderer.listen(nativeNode,
|
|
1845
|
+
on[key] = delegateObj;
|
|
1846
|
+
nativeRenderer.listen(nativeNode, key, delegateObj.delegate, isSvg);
|
|
1847
1847
|
}
|
|
1848
1848
|
|
|
1849
1849
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viewfly/core",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.12",
|
|
4
4
|
"description": "Viewfly is a simple and easy-to-use JavaScript framework with an intuitive development experience.",
|
|
5
5
|
"main": "./bundles/index.js",
|
|
6
6
|
"module": "./bundles/index.esm.js",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"bugs": {
|
|
51
51
|
"url": "https://github.com/viewfly/viewfly.git/issues"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "9e55375068bc3657f348f4b0be498111b61eee3c",
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"reflect-metadata": "^0.2.2"
|
|
56
56
|
}
|