Skip to content

Commit 893a6cb

Browse files
Fix demo in IE 11
Polyfill Map and Array.from using polyfill.io.
1 parent 272754a commit 893a6cb

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

demo/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/4.1.3/flatly/bootstrap.min.css"
2525
integrity="sha256-O7FfDCaEf9kSRN9b9kmWu8C3rhL1hxEpPHp+CTZ4pMk=" crossorigin="anonymous" />
2626
<link rel="stylesheet" href="styles.css" />
27+
28+
<script src="https://cdn.polyfill.io/v2/polyfill.js?features=Array.from,Map&flags=gated"></script>
2729
</head>
2830

2931
<body>

src/demo.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,16 @@ function displayPattern(pattern: string) {
3838
}
3939

4040
function onClickGenerate() {
41-
if (!$form.reportValidity()) {
42-
return;
41+
try {
42+
if (!$form.reportValidity()) {
43+
return;
44+
}
45+
} catch (ex) {
46+
// Ignore browsers that don't support reportValidity()
4347
}
4448

4549
let words = $input.value;
46-
const delimiter = $delimiter.selectedOptions[0].value;
50+
const delimiter = $delimiter.options[$delimiter.selectedIndex].value;
4751
const isCaseSensitive = $caseSensitive.checked;
4852
const isWhitespaceTrimmed = $trim.checked;
4953

src/utils/pattern.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { ICharTrie } from '../types/charTrie';
99
*/
1010
export function build(charTrie: ICharTrie): string {
1111
const patternSegments = Array.from(
12-
charTrie,
12+
[...charTrie],
1313
([head, suffixTrie]) => `${head}${build(suffixTrie)}`
1414
);
1515

0 commit comments

Comments
 (0)