resolve-id-refs
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/resolve-id-refs package

0.1.0 • Public • Published

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.

Readme

Keywords

none

Package Sidebar

Install

npm i resolve-id-refs

Weekly Downloads

27,865

Version

0.1.0

License

CC0-1.0

Last publish

Collaborators

  • shawnbot