Skip to content

Commit 2a2c550

Browse files
Merge pull request #345 from preactjs/print-debug
2 parents 62a02a1 + d6f5728 commit 2a2c550

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/adapter/debug.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,11 @@ export function printCommit(data: number[]) {
250250
case MsgTypes.REMOVE_VNODE: {
251251
const unmounts = data[i + 1];
252252
i += 2;
253-
const len = i + unmounts;
254253
console.log(`total unmounts: ${unmounts}`);
255-
for (; i < len; i++) {
256-
console.log(` Remove: %c${data[i]}`, "color: red");
254+
for (let j = 0; j < unmounts; j++) {
255+
console.log(` Remove: %c${data[i + j]}`, "color: red");
257256
}
257+
i += unmounts - 1;
258258
break;
259259
}
260260
case MsgTypes.REORDER_CHILDREN: {
@@ -304,6 +304,21 @@ export function printCommit(data: number[]) {
304304
i++;
305305
break;
306306
}
307+
case MsgTypes.HOC_NODES: {
308+
const id = data[i + 1];
309+
const count = data[i + 2];
310+
const hocs = [];
311+
for (let j = 0; j < count; j++) {
312+
hocs.push(strings[data[i + 3 + j] - 1]);
313+
}
314+
console.log(
315+
` Add HOCs: %c${id} %c${hocs.join(", ")}`,
316+
"color: yellow",
317+
"font-size: 10px; color: #ccc; background-color: #444; padding: .1rem .3rem; border-radius: 2px;",
318+
);
319+
i += 2 + count;
320+
break;
321+
}
307322
default: {
308323
console.log("Not implemented", data[i]);
309324
}

0 commit comments

Comments
 (0)