Skip to content

Commit

Permalink
Change ArtificialNode workaround to be resilient to renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
etrepum committed May 17, 2024
1 parent d378edb commit b21494e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/lexical/src/LexicalEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,16 @@ export function createEditor(editorConfig?: CreateEditorArgs): LexicalEditor {
}
// Ensure custom nodes implement required methods.
if (__DEV__) {
// ArtificialNode__DO_NOT_USE can get renamed, so we use the type
const nodeType =
Object.prototype.hasOwnProperty.call(klass, 'getType') &&
klass.getType();
const name = klass.name;
if (name !== 'RootNode' && name !== 'ArtificialNode__DO_NOT_USE') {
if (
name !== 'RootNode' &&
nodeType !== 'root' &&
nodeType !== 'artificial'
) {
const proto = klass.prototype;
['getType', 'clone'].forEach((method) => {
// eslint-disable-next-line no-prototype-builtins
Expand Down

0 comments on commit b21494e

Please sign in to comment.