Socket
Book a DemoInstallSign in
Socket

winkblue

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

winkblue

A simple DOM observer

latest
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

winkblue

NPM Version

A simple DOM observer which API compatible to sentinel-js

Installation

CDN

<script src="https://unpkg.com/winkblue/dist/winkblue.umd.js"></script>
<script>
  const { winkblue } = Winkblue;

  // or

  const winkblue = new Winkblue.Winkblue();

  // or

  const winkblue = Winkblue.Winkblue.new();
</script>

CDN + ESM

<script type="importmap">
  {
    "imports": {
      "winkblue": "https://esm.sh/winkblue"
    }
  }
</script>

<script type="module">
  import { winkblue } from 'winkblue';

  // or

  import { Winkblue } from 'winkblue';
  const winkblue = new Winkblue();

  // or

  import { Winkblue } from 'winkblue';
  const winkblue = Winkblue.new();
</script>

Usage

// Start observing elements by class
winkblue.on('.dynamic-load-components', (el) => {
  // do something on `el`
});

// Stop observing elements by class
winkblue.off('.dynamic-load-components');

// Stop observing all elements
winkblue.reset();

options

// triggers callback if the element had been removed then attached back on document
// default: false
winkblue.options.forgetHiddenElement = true;

Why?

  • sentinel-js can not find the display: none; elements.
  • sentinel-js can not trigger multiple times if multiple selectors match the same element.
  • sentinel-js can not work with multiple instances.

Limitation

  • if you reuse the same element instance, the callback will not be triggered unless you set options.forgetHiddenElement to true

Playground

LICENSE

ISC

FAQs

Package last updated on 23 Sep 2024

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.