Skip to content

Commit

Permalink
breaking: remove Node#__clone in Babel 8
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Jul 28, 2021
1 parent 760023d commit 3073f58
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/babel-parser/src/parser/node.js
Expand Up @@ -26,9 +26,12 @@ class Node implements NodeBase {
trailingComments: Array<Comment>;
innerComments: Array<Comment>;
extra: { [key: string]: any };
}
const NodePrototype = Node.prototype;

// todo(Babel 8): remove this method in Babel 8
__clone(): this {
if (!process.env.BABEL_8_BREAKING) {
// $FlowIgnore
NodePrototype.__clone = function (): Node {
// $FlowIgnore
const newNode: any = new Node();
const keys = Object.keys(this);
Expand All @@ -40,15 +43,13 @@ class Node implements NodeBase {
key !== "trailingComments" &&
key !== "innerComments"
) {
// $FlowIgnore
newNode[key] = this[key];
}
}

return newNode;
}
};
}
const NodePrototype = Node.prototype;

function clonePlaceholder(node: any): any {
return cloneIdentifier(node);
Expand Down

0 comments on commit 3073f58

Please sign in to comment.