Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type definition for idiomoph #16

Open
atulbhatt-system32 opened this issue Nov 8, 2023 · 3 comments
Open

Type definition for idiomoph #16

atulbhatt-system32 opened this issue Nov 8, 2023 · 3 comments

Comments

@atulbhatt-system32
Copy link

Typescript support for idiomorph

@jollytoad
Copy link

I've used this based on a flick through the code...

declare interface Idiomorph {
  morph: (oldNode: Element | Document, newContent?: string | Element | Iterable<Element> | null, options?: {
    morphStyle?: "innerHTML" | "outerHTML";
    ignoreActive?: boolean;
    ignoreActiveValue?: boolean;
    head?: {
      style?: "merge" | "append" | "morph" | "none";
    };
    callbacks?: {
      beforeNodeAdded: (node: ChildNode) => void | boolean;
      afterNodeAdded: (node: ChildNode) => void;
      beforeNodeMorphed: (oldNode: Element, newNode: Element) => void | boolean;
      afterNodeMorphed: (oldNode: Element, newNode: Element) => void;
      beforeNodeRemoved: (node: ChildNode) => void | boolean;
      afterNodeRemoved: (node: ChildNode) => void;
    };
  }) => undefined | Iterable<ChildNode>;
}

declare let Idiomorph: Idiomorph;

@1cg
Copy link
Contributor

1cg commented Dec 15, 2023

Happy to accept a PR for this

@delaneyj
Copy link
Contributor

delaneyj commented Apr 3, 2024

I've ported idiomorph to TS, might be useful for the typedefs
https://github.com/delaneyj/datastar/blob/main/library/src/lib/external/idiomorph.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants