Skip to content

Is their a way to reset all properties on a group and it's children to default values? Or clone() a Node without causing duplicates to be added to the stage? #1200

Answered by lavrton
MartinDawson asked this question in Q&A
Discussion options

You must be logged in to vote

@magicienap are there issues with the first approach?

cell.text.setAttrs({
  ...this.cachedCellText.getAttrs(),
});

Currently, there is no simple API to reset to defaults. Only if you do that manually. Some options are:

// (1) set all to nulls (it will reset to defaults
const oldAttrs = node.getAttrs();
const resetValues = {};
for (var key in oldAttrs) {
  resetValues[key] = null;
}
node.setAttrs(resetValues);

// (2) probably this will work too:
node.attrs = {};
node._clearCache();

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@MartinDawson
Comment options

Answer selected by MartinDawson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants