Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

auto-elems-from-dom

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

auto-elems-from-dom

Get elements from DOM (reference to DOM, document fragment) or string easily!

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

auto-elems-from-dom

Get elements from DOM (reference to DOM, document fragment) or string easily!

About

  • pass DOM (reference to DOM, document fragment) or string
  • get elements' references and DOM (reference to DOM, document fragment)

Installation

$ npm install --save auto-elems-from-dom

Polyfill range.createContextualFragment (ie9, ie10, ...)

require('auto-elems-from-dom/polyfill');

Usage

var autoElemsFromDom = require('auto-elems-from-dom');

// autoElemsFromDom(dom, type, name, flat)

// type: attr, name: data-elo
var a = autoElemsFromDom('<div data-elo="s1"><div data-elo="s2">111</div></div><div data-elo="s1">111</div>', 'attr', 'data-elo');
console.log(a, a.elems); // dom, elems ({s1: [], s2: []})

// type: attr, name: mega-elo
var a1 = autoElemsFromDom('<div mega-elo="s1"><div mega-elo="s2">111</div></div><div mega-elo="s1">111</div>', 'attr', 'mega-elo');
console.log(a1, a1.elems); // dom, elems ({s1: [], s2: []})

// type: data, name: elo
var b = autoElemsFromDom('<div data-elo="s1" class="elo-s1"><div data-elo="s2" class="dssd elo-s2 assdsd">111</div></div><div data-elo="s1" class="ss elo-s1">111</div>', 'data', 'elo');
console.log(b, b.elems); // dom, elems ({s1: [], s2: []})

// type: class, name: elo
var c = autoElemsFromDom('<div class="elo-s1"><div class="dssd elo-s2 assdsd">111</div></div><div class="ss elo-s1">111</div>', 'class', 'elo');
console.log(c, c.elems); // dom, elems ({s1: [], s2: []})

// type: class, name: elo, flat: true
var d = autoElemsFromDom('<div class="elo-s1"><div class="dssd elo-s2 assdsd">111</div></div><div class="ss' +
 ' elo-s1">111</div>', 'class', 'elo', true);
console.log(d, d.s1, d.s2); // dom, elems (dom.s1, dom.s2)

Changelog

View on github.

Keywords

FAQs

Package last updated on 26 Jul 2016

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc