Skip to content

Commit ec8663a

Browse files
committed
feat(polyfill): Move querySelector polyfill from jitsi-meet and migrate to TypeScript
Moves the querySelector/querySelectorAll polyfill from jitsi-meet repository to js-utils for better reusability across Jitsi projects. Converts the implementation to TypeScript and adds robust support for Document, DocumentFragment, and Element node types to ensure the polyfill works correctly across all supported DOM API surfaces. Changes: - Moved polyfill from jitsi-meet to @jitsi/js-utils - Migrated to TypeScript with full type safety - Added proper function overloads with boolean parameter pattern to avoid 'as any' assertions - Implemented _getSearchElements() helper to handle Document/DocumentFragment/Element nodes - Updated querySelector/querySelectorAll to check root elements before searching descendants - Simplified internal functions to only accept Element type - Added try-catch blocks for complex selectors when checking root element matches - Updated tsconfig.json to include the TypeScript polyfill - All internal functions use clean overload pattern for type-safe boolean parameters Benefits: - Shared polyfill reduces code duplication across Jitsi projects - TypeScript provides better type safety and IDE support - document.querySelector('html') correctly finds the root element - documentFragment.querySelector() works properly - XML documents with any root element name are supported - Complex selectors like 'body > div' work correctly with Document nodes
1 parent e02504c commit ec8663a

File tree

4 files changed

+398
-282
lines changed

4 files changed

+398
-282
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"browser-detection/",
4545
"json.ts",
4646
"jitsi-local-storage/",
47+
"polyfills/",
4748
"random/",
4849
"transport/",
4950
"types/",

polyfills/querySelectorPolyfill.js

Lines changed: 0 additions & 282 deletions
This file was deleted.

0 commit comments

Comments
 (0)