Skip to content

Commit

Permalink
revert Fragment BS
Browse files Browse the repository at this point in the history
TypeScript 5.7 broke the dom-chef Fragment implementation so just
avoid using Fragment entirely until i figure out a workaround.

fuck this shit
  • Loading branch information
scheibo committed Dec 16, 2024
1 parent f654554 commit a61b063
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
5 changes: 2 additions & 3 deletions src/tools/display/debug.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as engine from '../../pkg';
import {LAYOUT, LE} from '../../pkg/data';
import * as gen1 from '../../pkg/gen1';

import {Fragment} from './dom';
import {Battle, Gen, Generation, adapt} from './ui';
import * as util from './util';

Expand Down Expand Up @@ -100,11 +99,11 @@ const App = ({gen, data, error, seed}: {
}
frames.push(<Frame frame={partial || {}} gen={gen} showdown={showdown} last={last} />);

return <>
return <div>
{!!seed && <h1>0x{seed.toString(16).toUpperCase()}</h1>}
{frames}
{error && <pre className='error'><code>{error}</code></pre>}
</>;
</div>;
};

const Frame = ({frame, gen, showdown, last}: {
Expand Down
3 changes: 2 additions & 1 deletion src/tools/display/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,5 @@ export const h = (
return element;
};

export const Fragment = (props: {children: any}) => props.children as Fragment;
export const Fragment =
(typeof DocumentFragment === 'function' ? DocumentFragment : () => {}) as Fragment;
7 changes: 3 additions & 4 deletions src/tools/display/select.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/** @license MIT modified from Pixabay's https://github.com/Pixabay/JavaScript-autoComplete */
import {Fragment} from './dom';

const FRAME_MS = 20;
// const DELAY_MS = 150;
const HIDE_MS = 350;

export const Select = ({options, unmount, placeholder, render}: {
options: string[] ;
options: string[];
unmount?: Promise<void>;
placeholder?: string;
render?: (option: string, search: string) => JSX.Element;
Expand All @@ -20,8 +19,8 @@ export const Select = ({options, unmount, placeholder, render}: {

render ||= option => input.value
// ? <span dangerouslySetInnerHTML={{__html: searcher.highlight(option)}}></span>
? <>{option}</>
: <>{option}</>;
? <span>{option}</span>
: <span>{option}</span>;

let maxHeight = 0;
let offsetHeight = 0;
Expand Down

0 comments on commit a61b063

Please sign in to comment.