New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

attrs-observer

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

attrs-observer

Observe the DOM property change and injection condition to determine whether to modify the property

latest
Source
npmnpm
Version
1.0.3
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

📦 Installation

npm install attrs-observer

🔨 Usage

import AttrsObserver from 'attrs-observer'

const target = document.querySelector('div')

const observer = new AttrsObserver();

observer.observe(target,
    (target, from, to) => {
        console.log(target, from, to)
        //如果这里返回true 属性就不会设置下去
    },
    (target, from, to) => {
        console.log(target, from, to)
    }
)
//todo 这时候修改 style 或者calss 都会被检查到
observer.unobserve(target)

🖥 API

Class AttrsObserver

Hierarchy

  • AttrsObserver

Index

Constructors

  • constructor

Properties

Methods

Constructors

constructor

  • new AttrsObserver(): AttrsObserver

  • Returns AttrsObserver

Methods

observe

  • observe(target: HTMLElement, preHook: Hook, afterHook: Hook): AttrsObserver

    • Defined in [AttrsObserver.ts:195]

    开始观察

    Parameters

    • target: HTMLElement

      目标对象

    • preHook: Hook

      在样式或者类名改变之前的回调 ps 如果返回 true 那么样式或者类名就不会变

    • afterHook: Hook

      在样式或者类名改变之后的回调

    Returns AttrsObserver

unobserve

  • unobserve(target: HTMLElement): boolean

  • 解除观察

    Parameters

    • target: HTMLElement

      目标对象

    Returns boolean

Keywords

observe

FAQs

Package last updated on 27 Mar 2021

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