@viewfly/core 0.2.2 → 0.2.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/bundles/foundation/_utils.d.ts +1 -0
- package/bundles/foundation/injection-tokens.d.ts +14 -14
- package/bundles/index.esm.js +58 -53
- package/bundles/index.js +58 -53
- package/package.json +1 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
export type NativeNode = Record<string, any>;
|
|
2
2
|
export declare abstract class NativeRenderer<ElementNode = NativeNode, TextNode = NativeNode> {
|
|
3
|
-
abstract createElement(name: string): ElementNode;
|
|
4
|
-
abstract createTextNode(textContent: string): TextNode;
|
|
5
|
-
abstract setProperty(node: ElementNode, key: string, value: any): void;
|
|
6
|
-
abstract appendChild(parent: ElementNode, newChild: ElementNode | TextNode): void;
|
|
7
|
-
abstract prependChild(parent: ElementNode, newChild: ElementNode | TextNode): void;
|
|
8
|
-
abstract removeProperty(node: ElementNode, key: string): void;
|
|
9
|
-
abstract setStyle(target: ElementNode, key: string, value: any): void;
|
|
10
|
-
abstract removeStyle(target: ElementNode, key: string): void;
|
|
11
|
-
abstract setClass(target: ElementNode, value: string): void;
|
|
12
|
-
abstract listen<T = any>(node: ElementNode, type: string, callback: (ev: T) => any): void;
|
|
13
|
-
abstract unListen(node: ElementNode, type: string, callback: (ev: any) => any): void;
|
|
14
|
-
abstract remove(node: ElementNode | TextNode): void;
|
|
15
|
-
abstract syncTextContent(target: TextNode, content: string): void;
|
|
16
|
-
abstract insertAfter(newNode: ElementNode | TextNode, ref: ElementNode | TextNode): void;
|
|
3
|
+
abstract createElement(name: string, isSvg: boolean): ElementNode;
|
|
4
|
+
abstract createTextNode(textContent: string, isSvg: boolean): TextNode;
|
|
5
|
+
abstract setProperty(node: ElementNode, key: string, value: any, isSvg: boolean): void;
|
|
6
|
+
abstract appendChild(parent: ElementNode, newChild: ElementNode | TextNode, isSvg: boolean): void;
|
|
7
|
+
abstract prependChild(parent: ElementNode, newChild: ElementNode | TextNode, isSvg: boolean): void;
|
|
8
|
+
abstract removeProperty(node: ElementNode, key: string, isSvg: boolean): void;
|
|
9
|
+
abstract setStyle(target: ElementNode, key: string, value: any, isSvg: boolean): void;
|
|
10
|
+
abstract removeStyle(target: ElementNode, key: string, isSvg: boolean): void;
|
|
11
|
+
abstract setClass(target: ElementNode, value: string, isSvg: boolean): void;
|
|
12
|
+
abstract listen<T = any>(node: ElementNode, type: string, callback: (ev: T) => any, isSvg: boolean): void;
|
|
13
|
+
abstract unListen(node: ElementNode, type: string, callback: (ev: any) => any, isSvg: boolean): void;
|
|
14
|
+
abstract remove(node: ElementNode | TextNode, isSvg: boolean): void;
|
|
15
|
+
abstract syncTextContent(target: TextNode, content: string, isSvg: boolean): void;
|
|
16
|
+
abstract insertAfter(newNode: ElementNode | TextNode, ref: ElementNode | TextNode, isSvg: boolean): void;
|
|
17
17
|
}
|
package/bundles/index.esm.js
CHANGED
|
@@ -1212,14 +1212,15 @@ function createRenderer(component, nativeRenderer, version) {
|
|
|
1212
1212
|
let isInit = true;
|
|
1213
1213
|
return function render(host) {
|
|
1214
1214
|
if (isInit) {
|
|
1215
|
-
nativeRenderer.setProperty(host, 'viewfly-version', version);
|
|
1215
|
+
nativeRenderer.setProperty(host, 'viewfly-version', version, false);
|
|
1216
1216
|
isInit = false;
|
|
1217
1217
|
const atom = {
|
|
1218
1218
|
jsxNode: component,
|
|
1219
1219
|
parent: null,
|
|
1220
1220
|
sibling: null,
|
|
1221
1221
|
child: null,
|
|
1222
|
-
nativeNode: null
|
|
1222
|
+
nativeNode: null,
|
|
1223
|
+
isSvg: false
|
|
1223
1224
|
};
|
|
1224
1225
|
componentRender(nativeRenderer, component, atom, {
|
|
1225
1226
|
isParent: true,
|
|
@@ -1241,19 +1242,19 @@ function buildView(nativeRenderer, parentComponent, atom, context) {
|
|
|
1241
1242
|
let nativeNode;
|
|
1242
1243
|
let applyRefs = null;
|
|
1243
1244
|
if (atom.jsxNode instanceof JSXElement) {
|
|
1244
|
-
const { nativeNode: n, applyRefs: a } = createElement(nativeRenderer, atom.jsxNode);
|
|
1245
|
+
const { nativeNode: n, applyRefs: a } = createElement(nativeRenderer, atom.jsxNode, atom.isSvg);
|
|
1245
1246
|
nativeNode = n;
|
|
1246
1247
|
applyRefs = a;
|
|
1247
1248
|
}
|
|
1248
1249
|
else {
|
|
1249
|
-
nativeNode = createTextNode(nativeRenderer, atom.jsxNode);
|
|
1250
|
+
nativeNode = createTextNode(nativeRenderer, atom.jsxNode, atom.isSvg);
|
|
1250
1251
|
}
|
|
1251
1252
|
atom.nativeNode = nativeNode;
|
|
1252
1253
|
if (context.isParent) {
|
|
1253
|
-
nativeRenderer.prependChild(context.host, nativeNode);
|
|
1254
|
+
nativeRenderer.prependChild(context.host, nativeNode, atom.isSvg);
|
|
1254
1255
|
}
|
|
1255
1256
|
else {
|
|
1256
|
-
nativeRenderer.insertAfter(nativeNode, context.host);
|
|
1257
|
+
nativeRenderer.insertAfter(nativeNode, context.host, atom.isSvg);
|
|
1257
1258
|
}
|
|
1258
1259
|
if (atom.jsxNode instanceof JSXElement) {
|
|
1259
1260
|
const childContext = {
|
|
@@ -1367,15 +1368,15 @@ function diff(nativeRenderer, parentComponent, newAtom, oldAtom, context, expect
|
|
|
1367
1368
|
const host = context.host;
|
|
1368
1369
|
if (expectIndex - offset !== oldIndex) {
|
|
1369
1370
|
if (context.isParent) {
|
|
1370
|
-
nativeRenderer.prependChild(host, newAtom.nativeNode);
|
|
1371
|
+
nativeRenderer.prependChild(host, newAtom.nativeNode, newAtom.isSvg);
|
|
1371
1372
|
}
|
|
1372
1373
|
else {
|
|
1373
|
-
nativeRenderer.insertAfter(newAtom.nativeNode, host);
|
|
1374
|
+
nativeRenderer.insertAfter(newAtom.nativeNode, host, newAtom.isSvg);
|
|
1374
1375
|
}
|
|
1375
1376
|
}
|
|
1376
1377
|
context.host = newAtom.nativeNode;
|
|
1377
1378
|
context.isParent = false;
|
|
1378
|
-
const applyRefs = updateNativeNodeProperties(nativeRenderer, newAtom.jsxNode, oldAtom.jsxNode, newAtom.nativeNode);
|
|
1379
|
+
const applyRefs = updateNativeNodeProperties(nativeRenderer, newAtom.jsxNode, oldAtom.jsxNode, newAtom.nativeNode, newAtom.isSvg);
|
|
1379
1380
|
if (newAtom.child) {
|
|
1380
1381
|
diff(nativeRenderer, parentComponent, newAtom.child, oldAtom.child, {
|
|
1381
1382
|
host: newAtom.nativeNode,
|
|
@@ -1396,7 +1397,7 @@ function diff(nativeRenderer, parentComponent, newAtom, oldAtom, context, expect
|
|
|
1396
1397
|
commits.push(() => {
|
|
1397
1398
|
const nativeNode = oldAtom.nativeNode;
|
|
1398
1399
|
if (newAtom.jsxNode.text !== oldAtom.jsxNode.text) {
|
|
1399
|
-
nativeRenderer.syncTextContent(nativeNode, newAtom.jsxNode.text);
|
|
1400
|
+
nativeRenderer.syncTextContent(nativeNode, newAtom.jsxNode.text, newAtom.isSvg);
|
|
1400
1401
|
}
|
|
1401
1402
|
newAtom.nativeNode = nativeNode;
|
|
1402
1403
|
context.host = nativeNode;
|
|
@@ -1496,10 +1497,10 @@ function reuseComponentView(nativeRenderer, newAtom, reusedAtom, context, moveVi
|
|
|
1496
1497
|
else {
|
|
1497
1498
|
if (moveView) {
|
|
1498
1499
|
if (context.isParent) {
|
|
1499
|
-
nativeRenderer.prependChild(context.host, atom.nativeNode);
|
|
1500
|
+
nativeRenderer.prependChild(context.host, atom.nativeNode, atom.isSvg);
|
|
1500
1501
|
}
|
|
1501
1502
|
else {
|
|
1502
|
-
nativeRenderer.insertAfter(atom.nativeNode, context.host);
|
|
1503
|
+
nativeRenderer.insertAfter(atom.nativeNode, context.host, atom.isSvg);
|
|
1503
1504
|
}
|
|
1504
1505
|
}
|
|
1505
1506
|
context.isParent = false;
|
|
@@ -1513,7 +1514,7 @@ function reuseComponentView(nativeRenderer, newAtom, reusedAtom, context, moveVi
|
|
|
1513
1514
|
function cleanView(nativeRenderer, atom, isClean) {
|
|
1514
1515
|
if (atom.nativeNode) {
|
|
1515
1516
|
if (!isClean) {
|
|
1516
|
-
nativeRenderer.remove(atom.nativeNode);
|
|
1517
|
+
nativeRenderer.remove(atom.nativeNode, atom.isSvg);
|
|
1517
1518
|
isClean = true;
|
|
1518
1519
|
}
|
|
1519
1520
|
if (atom.jsxNode instanceof JSXElement) {
|
|
@@ -1543,67 +1544,71 @@ function componentRender(nativeRenderer, component, from, context) {
|
|
|
1543
1544
|
}
|
|
1544
1545
|
component.rendered();
|
|
1545
1546
|
}
|
|
1546
|
-
function createChainByComponentFactory(jsxComponent, parent) {
|
|
1547
|
+
function createChainByComponentFactory(jsxComponent, parent, isSvg) {
|
|
1547
1548
|
return {
|
|
1548
1549
|
jsxNode: jsxComponent,
|
|
1549
1550
|
parent,
|
|
1550
1551
|
sibling: null,
|
|
1551
1552
|
child: null,
|
|
1552
|
-
nativeNode: null
|
|
1553
|
+
nativeNode: null,
|
|
1554
|
+
isSvg
|
|
1553
1555
|
};
|
|
1554
1556
|
}
|
|
1555
|
-
function createChainByJSXElement(component, element, parent) {
|
|
1557
|
+
function createChainByJSXElement(component, element, parent, isSvg) {
|
|
1558
|
+
isSvg = isSvg || element.type === 'svg';
|
|
1556
1559
|
const atom = {
|
|
1557
1560
|
jsxNode: element,
|
|
1558
1561
|
parent,
|
|
1559
1562
|
sibling: null,
|
|
1560
1563
|
child: null,
|
|
1561
|
-
nativeNode: null
|
|
1564
|
+
nativeNode: null,
|
|
1565
|
+
isSvg
|
|
1562
1566
|
};
|
|
1563
1567
|
if (Reflect.has(element.props, 'children')) {
|
|
1564
1568
|
const jsxChildren = element.props.children;
|
|
1565
|
-
const children = createChainByChildren(component, Array.isArray(jsxChildren) ? jsxChildren : [jsxChildren], atom, []);
|
|
1569
|
+
const children = createChainByChildren(component, Array.isArray(jsxChildren) ? jsxChildren : [jsxChildren], atom, [], isSvg);
|
|
1566
1570
|
link(atom, children);
|
|
1567
1571
|
}
|
|
1568
1572
|
return atom;
|
|
1569
1573
|
}
|
|
1570
|
-
function createChainByJSXText(node, parent) {
|
|
1574
|
+
function createChainByJSXText(node, parent, isSvg) {
|
|
1571
1575
|
return {
|
|
1572
1576
|
jsxNode: node,
|
|
1573
1577
|
parent,
|
|
1574
1578
|
sibling: null,
|
|
1575
1579
|
child: null,
|
|
1576
|
-
nativeNode: null
|
|
1580
|
+
nativeNode: null,
|
|
1581
|
+
isSvg
|
|
1577
1582
|
};
|
|
1578
1583
|
}
|
|
1579
|
-
function createChainByChildren(component, children, parent, atoms) {
|
|
1584
|
+
function createChainByChildren(component, children, parent, atoms, isSvg) {
|
|
1580
1585
|
for (const item of children) {
|
|
1581
|
-
if (item !== null && typeof item !== 'undefined') {
|
|
1586
|
+
if (item !== null && typeof item !== 'undefined' && typeof item !== 'boolean') {
|
|
1582
1587
|
if (item instanceof JSXElement) {
|
|
1583
|
-
atoms.push(createChainByJSXElement(component, item, parent));
|
|
1588
|
+
atoms.push(createChainByJSXElement(component, item, parent, isSvg));
|
|
1584
1589
|
continue;
|
|
1585
1590
|
}
|
|
1586
1591
|
if (item instanceof JSXComponent) {
|
|
1587
|
-
const childAtom = createChainByComponentFactory(item, parent);
|
|
1592
|
+
const childAtom = createChainByComponentFactory(item, parent, isSvg);
|
|
1588
1593
|
atoms.push(childAtom);
|
|
1589
1594
|
continue;
|
|
1590
1595
|
}
|
|
1591
1596
|
if (typeof item === 'string' && item.length) {
|
|
1592
|
-
atoms.push(createChainByJSXText(new JSXText(item), parent));
|
|
1597
|
+
atoms.push(createChainByJSXText(new JSXText(item), parent, isSvg));
|
|
1593
1598
|
continue;
|
|
1594
1599
|
}
|
|
1595
1600
|
if (Array.isArray(item)) {
|
|
1596
|
-
createChainByChildren(component, item, parent, atoms);
|
|
1601
|
+
createChainByChildren(component, item, parent, atoms, isSvg);
|
|
1597
1602
|
continue;
|
|
1598
1603
|
}
|
|
1599
|
-
atoms.push(createChainByJSXText(new JSXText(String(item)), parent));
|
|
1604
|
+
atoms.push(createChainByJSXText(new JSXText(String(item)), parent, isSvg));
|
|
1600
1605
|
}
|
|
1601
1606
|
}
|
|
1602
1607
|
return atoms;
|
|
1603
1608
|
}
|
|
1604
1609
|
function linkTemplate(template, component, parent) {
|
|
1605
1610
|
const children = Array.isArray(template) ? template : [template];
|
|
1606
|
-
const newChildren = createChainByChildren(component, children, parent, []);
|
|
1611
|
+
const newChildren = createChainByChildren(component, children, parent, [], parent.isSvg);
|
|
1607
1612
|
link(parent, newChildren);
|
|
1608
1613
|
}
|
|
1609
1614
|
function link(parent, children) {
|
|
@@ -1613,8 +1618,8 @@ function link(parent, children) {
|
|
|
1613
1618
|
}
|
|
1614
1619
|
parent.child = children[0] || null;
|
|
1615
1620
|
}
|
|
1616
|
-
function createElement(nativeRenderer, vNode) {
|
|
1617
|
-
const nativeNode = nativeRenderer.createElement(vNode.type);
|
|
1621
|
+
function createElement(nativeRenderer, vNode, isSvg) {
|
|
1622
|
+
const nativeNode = nativeRenderer.createElement(vNode.type, isSvg);
|
|
1618
1623
|
const props = vNode.props;
|
|
1619
1624
|
let bindingRefs;
|
|
1620
1625
|
const keys = Object.keys(props);
|
|
@@ -1625,21 +1630,21 @@ function createElement(nativeRenderer, vNode) {
|
|
|
1625
1630
|
if (key === 'class') {
|
|
1626
1631
|
const className = classToString(props[key]);
|
|
1627
1632
|
if (className) {
|
|
1628
|
-
nativeRenderer.setClass(nativeNode, className);
|
|
1633
|
+
nativeRenderer.setClass(nativeNode, className, isSvg);
|
|
1629
1634
|
}
|
|
1630
1635
|
continue;
|
|
1631
1636
|
}
|
|
1632
1637
|
if (key === 'style') {
|
|
1633
1638
|
const style = styleToObject(props.style);
|
|
1634
1639
|
Object.keys(style).forEach(key => {
|
|
1635
|
-
nativeRenderer.setStyle(nativeNode, key, style[key]);
|
|
1640
|
+
nativeRenderer.setStyle(nativeNode, key, style[key], isSvg);
|
|
1636
1641
|
});
|
|
1637
1642
|
continue;
|
|
1638
1643
|
}
|
|
1639
1644
|
if (/^on[A-Z]/.test(key)) {
|
|
1640
1645
|
const listener = props[key];
|
|
1641
1646
|
if (typeof listener === 'function') {
|
|
1642
|
-
bindEvent(nativeRenderer, vNode, key, nativeNode, listener);
|
|
1647
|
+
bindEvent(nativeRenderer, vNode, key, nativeNode, listener, isSvg);
|
|
1643
1648
|
}
|
|
1644
1649
|
continue;
|
|
1645
1650
|
}
|
|
@@ -1647,7 +1652,7 @@ function createElement(nativeRenderer, vNode) {
|
|
|
1647
1652
|
bindingRefs = props[key];
|
|
1648
1653
|
continue;
|
|
1649
1654
|
}
|
|
1650
|
-
nativeRenderer.setProperty(nativeNode, key, props[key]);
|
|
1655
|
+
nativeRenderer.setProperty(nativeNode, key, props[key], isSvg);
|
|
1651
1656
|
}
|
|
1652
1657
|
return {
|
|
1653
1658
|
nativeNode,
|
|
@@ -1656,24 +1661,25 @@ function createElement(nativeRenderer, vNode) {
|
|
|
1656
1661
|
}
|
|
1657
1662
|
};
|
|
1658
1663
|
}
|
|
1659
|
-
function createTextNode(nativeRenderer, child) {
|
|
1660
|
-
return nativeRenderer.createTextNode(child.text);
|
|
1664
|
+
function createTextNode(nativeRenderer, child, isSvg) {
|
|
1665
|
+
return nativeRenderer.createTextNode(child.text, isSvg);
|
|
1661
1666
|
}
|
|
1662
|
-
function updateNativeNodeProperties(nativeRenderer, newVNode, oldVNode, nativeNode) {
|
|
1667
|
+
function updateNativeNodeProperties(nativeRenderer, newVNode, oldVNode, nativeNode, isSvg) {
|
|
1663
1668
|
const changes = getObjectChanges(newVNode.props, oldVNode.props);
|
|
1664
1669
|
let unBindRefs;
|
|
1665
1670
|
let bindRefs;
|
|
1671
|
+
newVNode.on = oldVNode.on;
|
|
1666
1672
|
for (const [key, value] of changes.remove) {
|
|
1667
1673
|
if (key === 'children') {
|
|
1668
1674
|
continue;
|
|
1669
1675
|
}
|
|
1670
1676
|
if (key === 'class') {
|
|
1671
|
-
nativeRenderer.setClass(nativeNode, '');
|
|
1677
|
+
nativeRenderer.setClass(nativeNode, '', isSvg);
|
|
1672
1678
|
continue;
|
|
1673
1679
|
}
|
|
1674
1680
|
if (key === 'style') {
|
|
1675
1681
|
Object.keys(styleToObject(value)).forEach(styleName => {
|
|
1676
|
-
nativeRenderer.removeStyle(nativeNode, styleName);
|
|
1682
|
+
nativeRenderer.removeStyle(nativeNode, styleName, isSvg);
|
|
1677
1683
|
});
|
|
1678
1684
|
continue;
|
|
1679
1685
|
}
|
|
@@ -1681,7 +1687,7 @@ function updateNativeNodeProperties(nativeRenderer, newVNode, oldVNode, nativeNo
|
|
|
1681
1687
|
if (typeof value === 'function') {
|
|
1682
1688
|
const type = key.replace(/^on/, '').toLowerCase();
|
|
1683
1689
|
const oldOn = oldVNode.on;
|
|
1684
|
-
nativeRenderer.unListen(nativeNode, type, oldOn[type].delegate);
|
|
1690
|
+
nativeRenderer.unListen(nativeNode, type, oldOn[type].delegate, isSvg);
|
|
1685
1691
|
Reflect.deleteProperty(oldOn, type);
|
|
1686
1692
|
}
|
|
1687
1693
|
continue;
|
|
@@ -1690,7 +1696,7 @@ function updateNativeNodeProperties(nativeRenderer, newVNode, oldVNode, nativeNo
|
|
|
1690
1696
|
unBindRefs = value;
|
|
1691
1697
|
continue;
|
|
1692
1698
|
}
|
|
1693
|
-
nativeRenderer.removeProperty(nativeNode, key);
|
|
1699
|
+
nativeRenderer.removeProperty(nativeNode, key, isSvg);
|
|
1694
1700
|
}
|
|
1695
1701
|
for (const [key, newValue, oldValue] of changes.replace) {
|
|
1696
1702
|
if (key === 'children') {
|
|
@@ -1700,23 +1706,22 @@ function updateNativeNodeProperties(nativeRenderer, newVNode, oldVNode, nativeNo
|
|
|
1700
1706
|
const oldClassName = classToString(oldValue);
|
|
1701
1707
|
const newClassName = classToString(newValue);
|
|
1702
1708
|
if (oldClassName !== newClassName) {
|
|
1703
|
-
nativeRenderer.setClass(nativeNode, newClassName);
|
|
1709
|
+
nativeRenderer.setClass(nativeNode, newClassName, isSvg);
|
|
1704
1710
|
}
|
|
1705
1711
|
continue;
|
|
1706
1712
|
}
|
|
1707
1713
|
if (key === 'style') {
|
|
1708
1714
|
const styleChanges = getObjectChanges(styleToObject(newValue) || {}, styleToObject(oldValue) || {});
|
|
1709
1715
|
for (const [styleName] of styleChanges.remove) {
|
|
1710
|
-
nativeRenderer.removeStyle(nativeNode, styleName);
|
|
1716
|
+
nativeRenderer.removeStyle(nativeNode, styleName, isSvg);
|
|
1711
1717
|
}
|
|
1712
1718
|
for (const [styleName, styleValue] of [...styleChanges.add, ...styleChanges.replace]) {
|
|
1713
|
-
nativeRenderer.setStyle(nativeNode, styleName, styleValue);
|
|
1719
|
+
nativeRenderer.setStyle(nativeNode, styleName, styleValue, isSvg);
|
|
1714
1720
|
}
|
|
1715
1721
|
continue;
|
|
1716
1722
|
}
|
|
1717
1723
|
if (/^on[A-Z]/.test(key)) {
|
|
1718
1724
|
const listenType = key.replace(/^on/, '').toLowerCase();
|
|
1719
|
-
newVNode.on = oldVNode.on;
|
|
1720
1725
|
newVNode.on[listenType].listenFn = newValue;
|
|
1721
1726
|
continue;
|
|
1722
1727
|
}
|
|
@@ -1725,26 +1730,26 @@ function updateNativeNodeProperties(nativeRenderer, newVNode, oldVNode, nativeNo
|
|
|
1725
1730
|
bindRefs = newValue;
|
|
1726
1731
|
continue;
|
|
1727
1732
|
}
|
|
1728
|
-
nativeRenderer.setProperty(nativeNode, key, newValue);
|
|
1733
|
+
nativeRenderer.setProperty(nativeNode, key, newValue, isSvg);
|
|
1729
1734
|
}
|
|
1730
1735
|
for (const [key, value] of changes.add) {
|
|
1731
1736
|
if (key === 'children') {
|
|
1732
1737
|
continue;
|
|
1733
1738
|
}
|
|
1734
1739
|
if (key === 'class') {
|
|
1735
|
-
nativeRenderer.setClass(nativeNode, classToString(value));
|
|
1740
|
+
nativeRenderer.setClass(nativeNode, classToString(value), isSvg);
|
|
1736
1741
|
continue;
|
|
1737
1742
|
}
|
|
1738
1743
|
if (key === 'style') {
|
|
1739
1744
|
const styleObj = styleToObject(value);
|
|
1740
1745
|
Object.keys(styleObj).forEach(styleName => {
|
|
1741
|
-
nativeRenderer.setStyle(nativeNode, styleName, styleObj[styleName]);
|
|
1746
|
+
nativeRenderer.setStyle(nativeNode, styleName, styleObj[styleName], isSvg);
|
|
1742
1747
|
});
|
|
1743
1748
|
continue;
|
|
1744
1749
|
}
|
|
1745
1750
|
if (/^on[A-Z]/.test(key)) {
|
|
1746
1751
|
if (typeof value === 'function') {
|
|
1747
|
-
bindEvent(nativeRenderer, newVNode, key, nativeNode, value);
|
|
1752
|
+
bindEvent(nativeRenderer, newVNode, key, nativeNode, value, isSvg);
|
|
1748
1753
|
}
|
|
1749
1754
|
continue;
|
|
1750
1755
|
}
|
|
@@ -1752,7 +1757,7 @@ function updateNativeNodeProperties(nativeRenderer, newVNode, oldVNode, nativeNo
|
|
|
1752
1757
|
bindRefs = value;
|
|
1753
1758
|
continue;
|
|
1754
1759
|
}
|
|
1755
|
-
nativeRenderer.setProperty(nativeNode, key, value);
|
|
1760
|
+
nativeRenderer.setProperty(nativeNode, key, value, isSvg);
|
|
1756
1761
|
}
|
|
1757
1762
|
return () => {
|
|
1758
1763
|
applyRefs(unBindRefs, nativeNode, false);
|
|
@@ -1767,7 +1772,7 @@ function applyRefs(refs, nativeNode, binding) {
|
|
|
1767
1772
|
}
|
|
1768
1773
|
}
|
|
1769
1774
|
}
|
|
1770
|
-
function bindEvent(nativeRenderer, vNode, key, nativeNode, listenFn) {
|
|
1775
|
+
function bindEvent(nativeRenderer, vNode, key, nativeNode, listenFn, isSvg) {
|
|
1771
1776
|
let on = vNode.on;
|
|
1772
1777
|
if (!on) {
|
|
1773
1778
|
vNode.on = on = {};
|
|
@@ -1781,7 +1786,7 @@ function bindEvent(nativeRenderer, vNode, key, nativeNode, listenFn) {
|
|
|
1781
1786
|
listenFn
|
|
1782
1787
|
};
|
|
1783
1788
|
on[type] = delegateObj;
|
|
1784
|
-
nativeRenderer.listen(nativeNode, type, delegate);
|
|
1789
|
+
nativeRenderer.listen(nativeNode, type, delegate, isSvg);
|
|
1785
1790
|
}
|
|
1786
1791
|
|
|
1787
1792
|
/**
|
|
@@ -1803,7 +1808,7 @@ class RootComponent extends Component {
|
|
|
1803
1808
|
}
|
|
1804
1809
|
|
|
1805
1810
|
const viewflyErrorFn = makeError('Viewfly');
|
|
1806
|
-
const VERSION = "0.2.
|
|
1811
|
+
const VERSION = "0.2.4";
|
|
1807
1812
|
function viewfly(config) {
|
|
1808
1813
|
const { context, nativeRenderer, autoUpdate, root } = Object.assign({ autoUpdate: true }, config);
|
|
1809
1814
|
const appProviders = [];
|
package/bundles/index.js
CHANGED
|
@@ -1214,14 +1214,15 @@ function createRenderer(component, nativeRenderer, version) {
|
|
|
1214
1214
|
let isInit = true;
|
|
1215
1215
|
return function render(host) {
|
|
1216
1216
|
if (isInit) {
|
|
1217
|
-
nativeRenderer.setProperty(host, 'viewfly-version', version);
|
|
1217
|
+
nativeRenderer.setProperty(host, 'viewfly-version', version, false);
|
|
1218
1218
|
isInit = false;
|
|
1219
1219
|
const atom = {
|
|
1220
1220
|
jsxNode: component,
|
|
1221
1221
|
parent: null,
|
|
1222
1222
|
sibling: null,
|
|
1223
1223
|
child: null,
|
|
1224
|
-
nativeNode: null
|
|
1224
|
+
nativeNode: null,
|
|
1225
|
+
isSvg: false
|
|
1225
1226
|
};
|
|
1226
1227
|
componentRender(nativeRenderer, component, atom, {
|
|
1227
1228
|
isParent: true,
|
|
@@ -1243,19 +1244,19 @@ function buildView(nativeRenderer, parentComponent, atom, context) {
|
|
|
1243
1244
|
let nativeNode;
|
|
1244
1245
|
let applyRefs = null;
|
|
1245
1246
|
if (atom.jsxNode instanceof JSXElement) {
|
|
1246
|
-
const { nativeNode: n, applyRefs: a } = createElement(nativeRenderer, atom.jsxNode);
|
|
1247
|
+
const { nativeNode: n, applyRefs: a } = createElement(nativeRenderer, atom.jsxNode, atom.isSvg);
|
|
1247
1248
|
nativeNode = n;
|
|
1248
1249
|
applyRefs = a;
|
|
1249
1250
|
}
|
|
1250
1251
|
else {
|
|
1251
|
-
nativeNode = createTextNode(nativeRenderer, atom.jsxNode);
|
|
1252
|
+
nativeNode = createTextNode(nativeRenderer, atom.jsxNode, atom.isSvg);
|
|
1252
1253
|
}
|
|
1253
1254
|
atom.nativeNode = nativeNode;
|
|
1254
1255
|
if (context.isParent) {
|
|
1255
|
-
nativeRenderer.prependChild(context.host, nativeNode);
|
|
1256
|
+
nativeRenderer.prependChild(context.host, nativeNode, atom.isSvg);
|
|
1256
1257
|
}
|
|
1257
1258
|
else {
|
|
1258
|
-
nativeRenderer.insertAfter(nativeNode, context.host);
|
|
1259
|
+
nativeRenderer.insertAfter(nativeNode, context.host, atom.isSvg);
|
|
1259
1260
|
}
|
|
1260
1261
|
if (atom.jsxNode instanceof JSXElement) {
|
|
1261
1262
|
const childContext = {
|
|
@@ -1369,15 +1370,15 @@ function diff(nativeRenderer, parentComponent, newAtom, oldAtom, context, expect
|
|
|
1369
1370
|
const host = context.host;
|
|
1370
1371
|
if (expectIndex - offset !== oldIndex) {
|
|
1371
1372
|
if (context.isParent) {
|
|
1372
|
-
nativeRenderer.prependChild(host, newAtom.nativeNode);
|
|
1373
|
+
nativeRenderer.prependChild(host, newAtom.nativeNode, newAtom.isSvg);
|
|
1373
1374
|
}
|
|
1374
1375
|
else {
|
|
1375
|
-
nativeRenderer.insertAfter(newAtom.nativeNode, host);
|
|
1376
|
+
nativeRenderer.insertAfter(newAtom.nativeNode, host, newAtom.isSvg);
|
|
1376
1377
|
}
|
|
1377
1378
|
}
|
|
1378
1379
|
context.host = newAtom.nativeNode;
|
|
1379
1380
|
context.isParent = false;
|
|
1380
|
-
const applyRefs = updateNativeNodeProperties(nativeRenderer, newAtom.jsxNode, oldAtom.jsxNode, newAtom.nativeNode);
|
|
1381
|
+
const applyRefs = updateNativeNodeProperties(nativeRenderer, newAtom.jsxNode, oldAtom.jsxNode, newAtom.nativeNode, newAtom.isSvg);
|
|
1381
1382
|
if (newAtom.child) {
|
|
1382
1383
|
diff(nativeRenderer, parentComponent, newAtom.child, oldAtom.child, {
|
|
1383
1384
|
host: newAtom.nativeNode,
|
|
@@ -1398,7 +1399,7 @@ function diff(nativeRenderer, parentComponent, newAtom, oldAtom, context, expect
|
|
|
1398
1399
|
commits.push(() => {
|
|
1399
1400
|
const nativeNode = oldAtom.nativeNode;
|
|
1400
1401
|
if (newAtom.jsxNode.text !== oldAtom.jsxNode.text) {
|
|
1401
|
-
nativeRenderer.syncTextContent(nativeNode, newAtom.jsxNode.text);
|
|
1402
|
+
nativeRenderer.syncTextContent(nativeNode, newAtom.jsxNode.text, newAtom.isSvg);
|
|
1402
1403
|
}
|
|
1403
1404
|
newAtom.nativeNode = nativeNode;
|
|
1404
1405
|
context.host = nativeNode;
|
|
@@ -1498,10 +1499,10 @@ function reuseComponentView(nativeRenderer, newAtom, reusedAtom, context, moveVi
|
|
|
1498
1499
|
else {
|
|
1499
1500
|
if (moveView) {
|
|
1500
1501
|
if (context.isParent) {
|
|
1501
|
-
nativeRenderer.prependChild(context.host, atom.nativeNode);
|
|
1502
|
+
nativeRenderer.prependChild(context.host, atom.nativeNode, atom.isSvg);
|
|
1502
1503
|
}
|
|
1503
1504
|
else {
|
|
1504
|
-
nativeRenderer.insertAfter(atom.nativeNode, context.host);
|
|
1505
|
+
nativeRenderer.insertAfter(atom.nativeNode, context.host, atom.isSvg);
|
|
1505
1506
|
}
|
|
1506
1507
|
}
|
|
1507
1508
|
context.isParent = false;
|
|
@@ -1515,7 +1516,7 @@ function reuseComponentView(nativeRenderer, newAtom, reusedAtom, context, moveVi
|
|
|
1515
1516
|
function cleanView(nativeRenderer, atom, isClean) {
|
|
1516
1517
|
if (atom.nativeNode) {
|
|
1517
1518
|
if (!isClean) {
|
|
1518
|
-
nativeRenderer.remove(atom.nativeNode);
|
|
1519
|
+
nativeRenderer.remove(atom.nativeNode, atom.isSvg);
|
|
1519
1520
|
isClean = true;
|
|
1520
1521
|
}
|
|
1521
1522
|
if (atom.jsxNode instanceof JSXElement) {
|
|
@@ -1545,67 +1546,71 @@ function componentRender(nativeRenderer, component, from, context) {
|
|
|
1545
1546
|
}
|
|
1546
1547
|
component.rendered();
|
|
1547
1548
|
}
|
|
1548
|
-
function createChainByComponentFactory(jsxComponent, parent) {
|
|
1549
|
+
function createChainByComponentFactory(jsxComponent, parent, isSvg) {
|
|
1549
1550
|
return {
|
|
1550
1551
|
jsxNode: jsxComponent,
|
|
1551
1552
|
parent,
|
|
1552
1553
|
sibling: null,
|
|
1553
1554
|
child: null,
|
|
1554
|
-
nativeNode: null
|
|
1555
|
+
nativeNode: null,
|
|
1556
|
+
isSvg
|
|
1555
1557
|
};
|
|
1556
1558
|
}
|
|
1557
|
-
function createChainByJSXElement(component, element, parent) {
|
|
1559
|
+
function createChainByJSXElement(component, element, parent, isSvg) {
|
|
1560
|
+
isSvg = isSvg || element.type === 'svg';
|
|
1558
1561
|
const atom = {
|
|
1559
1562
|
jsxNode: element,
|
|
1560
1563
|
parent,
|
|
1561
1564
|
sibling: null,
|
|
1562
1565
|
child: null,
|
|
1563
|
-
nativeNode: null
|
|
1566
|
+
nativeNode: null,
|
|
1567
|
+
isSvg
|
|
1564
1568
|
};
|
|
1565
1569
|
if (Reflect.has(element.props, 'children')) {
|
|
1566
1570
|
const jsxChildren = element.props.children;
|
|
1567
|
-
const children = createChainByChildren(component, Array.isArray(jsxChildren) ? jsxChildren : [jsxChildren], atom, []);
|
|
1571
|
+
const children = createChainByChildren(component, Array.isArray(jsxChildren) ? jsxChildren : [jsxChildren], atom, [], isSvg);
|
|
1568
1572
|
link(atom, children);
|
|
1569
1573
|
}
|
|
1570
1574
|
return atom;
|
|
1571
1575
|
}
|
|
1572
|
-
function createChainByJSXText(node, parent) {
|
|
1576
|
+
function createChainByJSXText(node, parent, isSvg) {
|
|
1573
1577
|
return {
|
|
1574
1578
|
jsxNode: node,
|
|
1575
1579
|
parent,
|
|
1576
1580
|
sibling: null,
|
|
1577
1581
|
child: null,
|
|
1578
|
-
nativeNode: null
|
|
1582
|
+
nativeNode: null,
|
|
1583
|
+
isSvg
|
|
1579
1584
|
};
|
|
1580
1585
|
}
|
|
1581
|
-
function createChainByChildren(component, children, parent, atoms) {
|
|
1586
|
+
function createChainByChildren(component, children, parent, atoms, isSvg) {
|
|
1582
1587
|
for (const item of children) {
|
|
1583
|
-
if (item !== null && typeof item !== 'undefined') {
|
|
1588
|
+
if (item !== null && typeof item !== 'undefined' && typeof item !== 'boolean') {
|
|
1584
1589
|
if (item instanceof JSXElement) {
|
|
1585
|
-
atoms.push(createChainByJSXElement(component, item, parent));
|
|
1590
|
+
atoms.push(createChainByJSXElement(component, item, parent, isSvg));
|
|
1586
1591
|
continue;
|
|
1587
1592
|
}
|
|
1588
1593
|
if (item instanceof JSXComponent) {
|
|
1589
|
-
const childAtom = createChainByComponentFactory(item, parent);
|
|
1594
|
+
const childAtom = createChainByComponentFactory(item, parent, isSvg);
|
|
1590
1595
|
atoms.push(childAtom);
|
|
1591
1596
|
continue;
|
|
1592
1597
|
}
|
|
1593
1598
|
if (typeof item === 'string' && item.length) {
|
|
1594
|
-
atoms.push(createChainByJSXText(new JSXText(item), parent));
|
|
1599
|
+
atoms.push(createChainByJSXText(new JSXText(item), parent, isSvg));
|
|
1595
1600
|
continue;
|
|
1596
1601
|
}
|
|
1597
1602
|
if (Array.isArray(item)) {
|
|
1598
|
-
createChainByChildren(component, item, parent, atoms);
|
|
1603
|
+
createChainByChildren(component, item, parent, atoms, isSvg);
|
|
1599
1604
|
continue;
|
|
1600
1605
|
}
|
|
1601
|
-
atoms.push(createChainByJSXText(new JSXText(String(item)), parent));
|
|
1606
|
+
atoms.push(createChainByJSXText(new JSXText(String(item)), parent, isSvg));
|
|
1602
1607
|
}
|
|
1603
1608
|
}
|
|
1604
1609
|
return atoms;
|
|
1605
1610
|
}
|
|
1606
1611
|
function linkTemplate(template, component, parent) {
|
|
1607
1612
|
const children = Array.isArray(template) ? template : [template];
|
|
1608
|
-
const newChildren = createChainByChildren(component, children, parent, []);
|
|
1613
|
+
const newChildren = createChainByChildren(component, children, parent, [], parent.isSvg);
|
|
1609
1614
|
link(parent, newChildren);
|
|
1610
1615
|
}
|
|
1611
1616
|
function link(parent, children) {
|
|
@@ -1615,8 +1620,8 @@ function link(parent, children) {
|
|
|
1615
1620
|
}
|
|
1616
1621
|
parent.child = children[0] || null;
|
|
1617
1622
|
}
|
|
1618
|
-
function createElement(nativeRenderer, vNode) {
|
|
1619
|
-
const nativeNode = nativeRenderer.createElement(vNode.type);
|
|
1623
|
+
function createElement(nativeRenderer, vNode, isSvg) {
|
|
1624
|
+
const nativeNode = nativeRenderer.createElement(vNode.type, isSvg);
|
|
1620
1625
|
const props = vNode.props;
|
|
1621
1626
|
let bindingRefs;
|
|
1622
1627
|
const keys = Object.keys(props);
|
|
@@ -1627,21 +1632,21 @@ function createElement(nativeRenderer, vNode) {
|
|
|
1627
1632
|
if (key === 'class') {
|
|
1628
1633
|
const className = classToString(props[key]);
|
|
1629
1634
|
if (className) {
|
|
1630
|
-
nativeRenderer.setClass(nativeNode, className);
|
|
1635
|
+
nativeRenderer.setClass(nativeNode, className, isSvg);
|
|
1631
1636
|
}
|
|
1632
1637
|
continue;
|
|
1633
1638
|
}
|
|
1634
1639
|
if (key === 'style') {
|
|
1635
1640
|
const style = styleToObject(props.style);
|
|
1636
1641
|
Object.keys(style).forEach(key => {
|
|
1637
|
-
nativeRenderer.setStyle(nativeNode, key, style[key]);
|
|
1642
|
+
nativeRenderer.setStyle(nativeNode, key, style[key], isSvg);
|
|
1638
1643
|
});
|
|
1639
1644
|
continue;
|
|
1640
1645
|
}
|
|
1641
1646
|
if (/^on[A-Z]/.test(key)) {
|
|
1642
1647
|
const listener = props[key];
|
|
1643
1648
|
if (typeof listener === 'function') {
|
|
1644
|
-
bindEvent(nativeRenderer, vNode, key, nativeNode, listener);
|
|
1649
|
+
bindEvent(nativeRenderer, vNode, key, nativeNode, listener, isSvg);
|
|
1645
1650
|
}
|
|
1646
1651
|
continue;
|
|
1647
1652
|
}
|
|
@@ -1649,7 +1654,7 @@ function createElement(nativeRenderer, vNode) {
|
|
|
1649
1654
|
bindingRefs = props[key];
|
|
1650
1655
|
continue;
|
|
1651
1656
|
}
|
|
1652
|
-
nativeRenderer.setProperty(nativeNode, key, props[key]);
|
|
1657
|
+
nativeRenderer.setProperty(nativeNode, key, props[key], isSvg);
|
|
1653
1658
|
}
|
|
1654
1659
|
return {
|
|
1655
1660
|
nativeNode,
|
|
@@ -1658,24 +1663,25 @@ function createElement(nativeRenderer, vNode) {
|
|
|
1658
1663
|
}
|
|
1659
1664
|
};
|
|
1660
1665
|
}
|
|
1661
|
-
function createTextNode(nativeRenderer, child) {
|
|
1662
|
-
return nativeRenderer.createTextNode(child.text);
|
|
1666
|
+
function createTextNode(nativeRenderer, child, isSvg) {
|
|
1667
|
+
return nativeRenderer.createTextNode(child.text, isSvg);
|
|
1663
1668
|
}
|
|
1664
|
-
function updateNativeNodeProperties(nativeRenderer, newVNode, oldVNode, nativeNode) {
|
|
1669
|
+
function updateNativeNodeProperties(nativeRenderer, newVNode, oldVNode, nativeNode, isSvg) {
|
|
1665
1670
|
const changes = getObjectChanges(newVNode.props, oldVNode.props);
|
|
1666
1671
|
let unBindRefs;
|
|
1667
1672
|
let bindRefs;
|
|
1673
|
+
newVNode.on = oldVNode.on;
|
|
1668
1674
|
for (const [key, value] of changes.remove) {
|
|
1669
1675
|
if (key === 'children') {
|
|
1670
1676
|
continue;
|
|
1671
1677
|
}
|
|
1672
1678
|
if (key === 'class') {
|
|
1673
|
-
nativeRenderer.setClass(nativeNode, '');
|
|
1679
|
+
nativeRenderer.setClass(nativeNode, '', isSvg);
|
|
1674
1680
|
continue;
|
|
1675
1681
|
}
|
|
1676
1682
|
if (key === 'style') {
|
|
1677
1683
|
Object.keys(styleToObject(value)).forEach(styleName => {
|
|
1678
|
-
nativeRenderer.removeStyle(nativeNode, styleName);
|
|
1684
|
+
nativeRenderer.removeStyle(nativeNode, styleName, isSvg);
|
|
1679
1685
|
});
|
|
1680
1686
|
continue;
|
|
1681
1687
|
}
|
|
@@ -1683,7 +1689,7 @@ function updateNativeNodeProperties(nativeRenderer, newVNode, oldVNode, nativeNo
|
|
|
1683
1689
|
if (typeof value === 'function') {
|
|
1684
1690
|
const type = key.replace(/^on/, '').toLowerCase();
|
|
1685
1691
|
const oldOn = oldVNode.on;
|
|
1686
|
-
nativeRenderer.unListen(nativeNode, type, oldOn[type].delegate);
|
|
1692
|
+
nativeRenderer.unListen(nativeNode, type, oldOn[type].delegate, isSvg);
|
|
1687
1693
|
Reflect.deleteProperty(oldOn, type);
|
|
1688
1694
|
}
|
|
1689
1695
|
continue;
|
|
@@ -1692,7 +1698,7 @@ function updateNativeNodeProperties(nativeRenderer, newVNode, oldVNode, nativeNo
|
|
|
1692
1698
|
unBindRefs = value;
|
|
1693
1699
|
continue;
|
|
1694
1700
|
}
|
|
1695
|
-
nativeRenderer.removeProperty(nativeNode, key);
|
|
1701
|
+
nativeRenderer.removeProperty(nativeNode, key, isSvg);
|
|
1696
1702
|
}
|
|
1697
1703
|
for (const [key, newValue, oldValue] of changes.replace) {
|
|
1698
1704
|
if (key === 'children') {
|
|
@@ -1702,23 +1708,22 @@ function updateNativeNodeProperties(nativeRenderer, newVNode, oldVNode, nativeNo
|
|
|
1702
1708
|
const oldClassName = classToString(oldValue);
|
|
1703
1709
|
const newClassName = classToString(newValue);
|
|
1704
1710
|
if (oldClassName !== newClassName) {
|
|
1705
|
-
nativeRenderer.setClass(nativeNode, newClassName);
|
|
1711
|
+
nativeRenderer.setClass(nativeNode, newClassName, isSvg);
|
|
1706
1712
|
}
|
|
1707
1713
|
continue;
|
|
1708
1714
|
}
|
|
1709
1715
|
if (key === 'style') {
|
|
1710
1716
|
const styleChanges = getObjectChanges(styleToObject(newValue) || {}, styleToObject(oldValue) || {});
|
|
1711
1717
|
for (const [styleName] of styleChanges.remove) {
|
|
1712
|
-
nativeRenderer.removeStyle(nativeNode, styleName);
|
|
1718
|
+
nativeRenderer.removeStyle(nativeNode, styleName, isSvg);
|
|
1713
1719
|
}
|
|
1714
1720
|
for (const [styleName, styleValue] of [...styleChanges.add, ...styleChanges.replace]) {
|
|
1715
|
-
nativeRenderer.setStyle(nativeNode, styleName, styleValue);
|
|
1721
|
+
nativeRenderer.setStyle(nativeNode, styleName, styleValue, isSvg);
|
|
1716
1722
|
}
|
|
1717
1723
|
continue;
|
|
1718
1724
|
}
|
|
1719
1725
|
if (/^on[A-Z]/.test(key)) {
|
|
1720
1726
|
const listenType = key.replace(/^on/, '').toLowerCase();
|
|
1721
|
-
newVNode.on = oldVNode.on;
|
|
1722
1727
|
newVNode.on[listenType].listenFn = newValue;
|
|
1723
1728
|
continue;
|
|
1724
1729
|
}
|
|
@@ -1727,26 +1732,26 @@ function updateNativeNodeProperties(nativeRenderer, newVNode, oldVNode, nativeNo
|
|
|
1727
1732
|
bindRefs = newValue;
|
|
1728
1733
|
continue;
|
|
1729
1734
|
}
|
|
1730
|
-
nativeRenderer.setProperty(nativeNode, key, newValue);
|
|
1735
|
+
nativeRenderer.setProperty(nativeNode, key, newValue, isSvg);
|
|
1731
1736
|
}
|
|
1732
1737
|
for (const [key, value] of changes.add) {
|
|
1733
1738
|
if (key === 'children') {
|
|
1734
1739
|
continue;
|
|
1735
1740
|
}
|
|
1736
1741
|
if (key === 'class') {
|
|
1737
|
-
nativeRenderer.setClass(nativeNode, classToString(value));
|
|
1742
|
+
nativeRenderer.setClass(nativeNode, classToString(value), isSvg);
|
|
1738
1743
|
continue;
|
|
1739
1744
|
}
|
|
1740
1745
|
if (key === 'style') {
|
|
1741
1746
|
const styleObj = styleToObject(value);
|
|
1742
1747
|
Object.keys(styleObj).forEach(styleName => {
|
|
1743
|
-
nativeRenderer.setStyle(nativeNode, styleName, styleObj[styleName]);
|
|
1748
|
+
nativeRenderer.setStyle(nativeNode, styleName, styleObj[styleName], isSvg);
|
|
1744
1749
|
});
|
|
1745
1750
|
continue;
|
|
1746
1751
|
}
|
|
1747
1752
|
if (/^on[A-Z]/.test(key)) {
|
|
1748
1753
|
if (typeof value === 'function') {
|
|
1749
|
-
bindEvent(nativeRenderer, newVNode, key, nativeNode, value);
|
|
1754
|
+
bindEvent(nativeRenderer, newVNode, key, nativeNode, value, isSvg);
|
|
1750
1755
|
}
|
|
1751
1756
|
continue;
|
|
1752
1757
|
}
|
|
@@ -1754,7 +1759,7 @@ function updateNativeNodeProperties(nativeRenderer, newVNode, oldVNode, nativeNo
|
|
|
1754
1759
|
bindRefs = value;
|
|
1755
1760
|
continue;
|
|
1756
1761
|
}
|
|
1757
|
-
nativeRenderer.setProperty(nativeNode, key, value);
|
|
1762
|
+
nativeRenderer.setProperty(nativeNode, key, value, isSvg);
|
|
1758
1763
|
}
|
|
1759
1764
|
return () => {
|
|
1760
1765
|
applyRefs(unBindRefs, nativeNode, false);
|
|
@@ -1769,7 +1774,7 @@ function applyRefs(refs, nativeNode, binding) {
|
|
|
1769
1774
|
}
|
|
1770
1775
|
}
|
|
1771
1776
|
}
|
|
1772
|
-
function bindEvent(nativeRenderer, vNode, key, nativeNode, listenFn) {
|
|
1777
|
+
function bindEvent(nativeRenderer, vNode, key, nativeNode, listenFn, isSvg) {
|
|
1773
1778
|
let on = vNode.on;
|
|
1774
1779
|
if (!on) {
|
|
1775
1780
|
vNode.on = on = {};
|
|
@@ -1783,7 +1788,7 @@ function bindEvent(nativeRenderer, vNode, key, nativeNode, listenFn) {
|
|
|
1783
1788
|
listenFn
|
|
1784
1789
|
};
|
|
1785
1790
|
on[type] = delegateObj;
|
|
1786
|
-
nativeRenderer.listen(nativeNode, type, delegate);
|
|
1791
|
+
nativeRenderer.listen(nativeNode, type, delegate, isSvg);
|
|
1787
1792
|
}
|
|
1788
1793
|
|
|
1789
1794
|
/**
|
|
@@ -1805,7 +1810,7 @@ class RootComponent extends Component {
|
|
|
1805
1810
|
}
|
|
1806
1811
|
|
|
1807
1812
|
const viewflyErrorFn = makeError('Viewfly');
|
|
1808
|
-
const VERSION = "0.2.
|
|
1813
|
+
const VERSION = "0.2.4";
|
|
1809
1814
|
function viewfly(config) {
|
|
1810
1815
|
const { context, nativeRenderer, autoUpdate, root } = Object.assign({ autoUpdate: true }, config);
|
|
1811
1816
|
const appProviders = [];
|
package/package.json
CHANGED