Options
All
  • Public
  • Public/Protected
  • All
Menu

@jinshub/url-fallback - v1.1.0

Index

Type aliases

FallbackElement: { fallbackData?: FallbackData; nextFallback?: FallbackElement; prevFallback?: FallbackElement } & (HTMLLinkElement | HTMLScriptElement | HTMLImageElement)

A fallback element is an ordinary HTMLElement instance with some custom properties that makes it a Doubly Linked List with extra data.

Functions

  • Start to capture error events of resources loaded by link, script and img elements, and replace error elements with fallback elements. The error element will dispatch a pre-url-fallback event before and a post-url-fallback event after fallback element generated.

    Parameters

    Returns RemoveErrorListener

    The function to remove the error event listener.

  • Get a list of matched substrings and their fallbacks based on one specific url and rules.

    Parameters

    • originalUrl: string

      The url of error resource.

    • config: ErrorListenerConfig

      The config passed to addErrorListener.

    Returns MatchFallback[]

    The list of matched substrings and their fallbacks.

  • getUrlFallbackHandler(config?: ErrorListenerConfig): { fallbackDataRecord: Record<string, FallbackData>; urlFallbackHandler: (errorEl: EventTarget) => void }
  • Get url fallback hander that replacing elements with fallback elements.

    Parameters

    Returns { fallbackDataRecord: Record<string, FallbackData>; urlFallbackHandler: (errorEl: EventTarget) => void }

    urlFallbackHandler and fallbackDataRecord

    • fallbackDataRecord: Record<string, FallbackData>
    • urlFallbackHandler: (errorEl: EventTarget) => void
        • (errorEl: EventTarget): void
        • Parameters

          • errorEl: EventTarget

          Returns void

Generated using TypeDoc