Skip to content
This repository has been archived by the owner on May 5, 2021. It is now read-only.

Commit

Permalink
[ADD] VNode: override toString to represent VNodes
Browse files Browse the repository at this point in the history
When implementing SHIFT+ENTER, I needed to inspect the 'insert' intent's
payload value, which had to be a LineBreakNode. However, all I could see
in the DevTools was "Object object". So I implemented an override of
toString on the VNode object so it could be conveniently inspected.
  • Loading branch information
Zynton committed Nov 25, 2019
1 parent b1eabeb commit 7d43bef
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/core/stores/VNode.ts
Expand Up @@ -65,6 +65,22 @@ export class VNode {
this._updateProperties();
id++;
}
/**
* @override
*/
toString(): string {
let string = this.constructor.name + '<' + this.type.toLowerCase();
if (this.hasChildren()) {
string += '>';
this.children.forEach(child => {
string += child.toString();
});
string += '<' + this.type.toLowerCase() + '>';
} else {
string += '/>';
}
return string;
}

//--------------------------------------------------------------------------
// Lifecycle
Expand Down

0 comments on commit 7d43bef

Please sign in to comment.