Socket
Book a DemoInstallSign in
Socket

arrosoir

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arrosoir

A function for basic DOM hydration

latest
Source
npmnpm
Version
1.0.2
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Arrosoir

CI

Small DOM hydration function for generated HTML.

Install

npm install arrosoir

Usage

import { hydrate } from 'arrosoir'
await hydrate(selector, url)

For example:

<script type="module">
    import { hydrate, params } from 'https://cdn.skypack.dev/arrosoir'

    const search = params(location.href)
    search.l ??= 10
    search.p ??= 0

    document.querySelector('button.load-more').addEventListener('click', async () => {
        search.p++
        await hydrate('ul.list', search.apply(location.href), { merge: true })
    })
</script>

The previous example fetches the page with a different query string.
The hydrate function will merge the new HTML into the existing DOM.

Options

  • merge: Append the new HTML to the selector.
  • history: Replace the current URL with the fetched one.

Keywords

arrosoir

FAQs

Package last updated on 07 Oct 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts