Commit 575964b
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 nodes1 parent 842fd3c commit 575964b
File tree
5 files changed
+400
-0
lines changed- polyfills
5 files changed
+400
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
0 commit comments