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

resolve-id-refs

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

resolve-id-refs

Resolve an ID reference list to an array of DOM elements

  • 0.1.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

resolve-id-refs

This module exports a function that resolves a HTML ID reference list into an array of elements. An ID reference list is a string in which one or more ids is separated by whitespace. Whitespace at the beginning and end of the string is trimmed, and any ID that is not found in the document raises an error.

var resolve = require('resolve-id-refs');
resolve('foo bar');
// => [
//   document.getElementById('foo'),
//   document.getElementById('bar')
// ]

API

resolve(ids<String> [, document<Document|DocumentFragment>]) => Array<Element>
  • The ids argument must be a string. Any other types will raise an error.
  • The second (optional) argument, document, should be a Document or DocumentFragment instance. Because DocumentFragment does not provide a getElementById() method, we use querySelector('[id="' + id + '"]').

Installation

This is a Node module intended for use with browser bundling tools, such as browserify and webpack. To install it in your project, run:

npm install --save resolve-id-refs

Then, require it in your bundle:

var resolve = require('resolve-id-refs');

See the tests for more examples of usage.

FAQs

Package last updated on 12 Oct 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