Skip to content

Commit

Permalink
revert hasOwn
Browse files Browse the repository at this point in the history
  • Loading branch information
2wheeh committed Apr 22, 2024
1 parent 12b5a50 commit 9481930
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion packages/lexical-code/src/CodeNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ const mapToPrismLanguage = (
): string | null | undefined => {
return language !== null &&
language !== undefined &&
Object.hasOwn(window.Prism.languages, language)
// eslint-disable-next-line no-prototype-builtins
window.Prism.languages.hasOwnProperty(language)
? language
: undefined;
};
Expand Down
18 changes: 12 additions & 6 deletions packages/lexical/src/LexicalEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,31 +448,37 @@ export function createEditor(editorConfig?: CreateEditorArgs): LexicalEditor {
if (name !== 'RootNode') {
const proto = klass.prototype;
['getType', 'clone'].forEach((method) => {
if (!Object.hasOwn(klass, method)) {
// eslint-disable-next-line no-prototype-builtins
if (!klass.hasOwnProperty(method)) {
console.warn(`${name} must implement static "${method}" method`);
}
});
if (
!Object.hasOwn(klass, 'importDOM') &&
Object.hasOwn(klass, 'exportDOM')
// eslint-disable-next-line no-prototype-builtins
!klass.hasOwnProperty('importDOM') &&
// eslint-disable-next-line no-prototype-builtins
klass.hasOwnProperty('exportDOM')
) {
console.warn(
`${name} should implement "importDOM" if using a custom "exportDOM" method to ensure HTML serialization (important for copy & paste) works as expected`,
);
}
if (proto instanceof DecoratorNode) {
if (!Object.hasOwn(proto, 'decorate')) {
// eslint-disable-next-line no-prototype-builtins
if (!proto.hasOwnProperty('decorate')) {
console.warn(
`${proto.constructor.name} must implement "decorate" method`,
);
}
}
if (!Object.hasOwn(klass, 'importJSON')) {
// eslint-disable-next-line no-prototype-builtins
if (!klass.hasOwnProperty('importJSON')) {
console.warn(
`${name} should implement "importJSON" method to ensure JSON and default HTML serialization works as expected`,
);
}
if (!Object.hasOwn(proto, 'exportJSON')) {
// eslint-disable-next-line no-prototype-builtins
if (!proto.hasOwnProperty('exportJSON')) {
console.warn(
`${name} should implement "exportJSON" method to ensure JSON and default HTML serialization works as expected`,
);
Expand Down

0 comments on commit 9481930

Please sign in to comment.