Skip to content

Commit 575964b

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 842fd3c commit 575964b

File tree

5 files changed

+400
-0
lines changed

5 files changed

+400
-0
lines changed

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ export * from './avatar/index.js';
22
export * from './browser-detection/index.js';
33
export * from './jitsi-local-storage/index.js';
44
export * from './json.ts';
5+
export * from './polyfills/index.ts';

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"browser-detection/",
4141
"json.ts",
4242
"jitsi-local-storage/",
43+
"polyfills/",
4344
"random/",
4445
"transport/",
4546
"types/",

polyfills/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './querySelectorPolyfill';

0 commit comments

Comments
 (0)