()
| 41 | |
| 42 | /** @returns The input types supported by this browser. */ |
| 43 | export function getSupportedInputTypes(): Set<string> { |
| 44 | // Result is cached. |
| 45 | if (supportedInputTypes) { |
| 46 | return supportedInputTypes; |
| 47 | } |
| 48 | |
| 49 | // We can't check if an input type is not supported until we're on the browser, so say that |
| 50 | // everything is supported when not on the browser. We don't use `Platform` here since it's |
| 51 | // just a helper function and can't inject it. |
| 52 | if (typeof document !== 'object' || !document) { |
| 53 | supportedInputTypes = new Set(candidateInputTypes); |
| 54 | return supportedInputTypes; |
| 55 | } |
| 56 | |
| 57 | let featureTestInput = document.createElement('input'); |
| 58 | supportedInputTypes = new Set( |
| 59 | candidateInputTypes.filter(value => { |
| 60 | featureTestInput.setAttribute('type', value); |
| 61 | return featureTestInput.type === value; |
| 62 | }), |
| 63 | ); |
| 64 | |
| 65 | return supportedInputTypes; |
| 66 | } |
no test coverage detected
searching dependent graphs…