diff --git a/packages/happy-dom/src/nodes/document/Document.ts b/packages/happy-dom/src/nodes/document/Document.ts index 98ffd6817..238d31851 100644 --- a/packages/happy-dom/src/nodes/document/Document.ts +++ b/packages/happy-dom/src/nodes/document/Document.ts @@ -672,6 +672,20 @@ export default class Document extends Node { public querySelector(selector: string): Element | null { return QuerySelector.querySelector(this, selector); } + /** + * Returns true if the command is supported. + * @deprecated + * @param _ Command. + * @returns True if the command is supported, false otherwise. + */ + public queryCommandSupported(_: string): boolean { + if (!arguments.length) { + throw new TypeError( + "Failed to execute 'queryCommandSupported' on 'Document': 1 argument required, but only 0 present." + ); + } + return true; + } /** * Returns an elements by class name. diff --git a/packages/happy-dom/test/nodes/document/Document.test.ts b/packages/happy-dom/test/nodes/document/Document.test.ts index 38bb790b5..bf4bf4ea6 100644 --- a/packages/happy-dom/test/nodes/document/Document.test.ts +++ b/packages/happy-dom/test/nodes/document/Document.test.ts @@ -599,6 +599,22 @@ describe('Document', () => { }); }); + describe('queryCommandSupported', () => { + it('Returns true if the command is supported.', () => { + // It's just a simple simulation implementation, and it will return true no matter what parameters are passed. + expect(document.queryCommandSupported('copy')).toBe(true); + expect(document.queryCommandSupported('selectall')).toBe(true); + }); + it('Throws an error if the command is not passed.', () => { + // @ts-ignore - Intentionally testing without parameters. + expect(() => document.queryCommandSupported()).toThrowError( + new TypeError( + "Failed to execute 'queryCommandSupported' on 'Document': 1 argument required, but only 0 present." + ) + ); + }); + }); + describe('getElementsByClassName()', () => { it('Returns an elements by class name.', () => { const element = document.createElement('div');