Skip to content

Commit 3782e24

Browse files
committed
refactor: rename syncArr to patch
1 parent 1db512c commit 3782e24

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

src/devtools-ui/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
getData,
1616
getOthersData,
1717
makeElementTree,
18-
syncArr
18+
patch
1919
} from './utils';
2020
import agent from './agent';
2121
import Devtools from './components/Devtools';
@@ -99,7 +99,7 @@ devtools
9999
/* eslint-disable no-unused-vars */
100100
var oldArr = elementView.data.nodes;
101101
var newArr = makeElementTree(nodes, []);
102-
elementView.data.nodes = syncArr(oldArr, newArr, []);
102+
elementView.data.nodes = patch(oldArr, newArr);
103103
/* eslint-enable no-unused-vars */
104104
elementView.$update();
105105
})

src/devtools-ui/utils/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {enter, exit} from './inspectComponent';
1212
import getData from './getData';
1313
import getOthersData from './getOthersData';
1414
import makeElementTree from './makeElementTree';
15-
import syncArr from './syncArr';
15+
import patch from './patch';
1616

1717
export {
1818
isPrimitive,
@@ -31,7 +31,7 @@ export {
3131
getData,
3232
getOthersData,
3333
makeElementTree,
34-
syncArr,
34+
patch,
3535
enter,
3636
exit
3737
};

src/devtools-ui/utils/syncArr.js renamed to src/devtools-ui/utils/patch.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import {findElementByUUIDNonRecursive} from "./findElement";
22

3-
export default function syncArr(oldArr, newArr, container) {
3+
// reuse old nodes
4+
export default function patch(oldArr, newArr) {
5+
const container = [];
46
for (var i = 0; i < newArr.length; i++) {
57
var newNode = newArr[i];
68
var oldNode = findElementByUUIDNonRecursive(oldArr, newArr[i].uuid);
79
if (oldNode) {
810
if (JSON.stringify(oldNode) !== JSON.stringify(newNode)) {
911
oldNode.name = newNode.name;
1012
oldNode.isIncluded = newNode.isIncluded;
11-
oldNode.childNodes = syncArr(oldNode.childNodes, newNode.childNodes, []);
13+
oldNode.childNodes = patch(oldNode.childNodes, newNode.childNodes, []);
1214
}
1315
container.push(oldNode);
1416
} else {

src/devtools-ui/utils/printInConsole.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default function(uuid) {
55
`devtoolsModel.print(${JSON.stringify(uuid)})`,
66
function(result, isException) {
77
if (isException) {
8-
log("Inspect Error: ", isException);
8+
log("Print Error: ", isException);
99
}
1010
}
1111
);

0 commit comments

Comments
 (0)