Skip to content

An ES-spec-compliant shim/polyfill/replacement for the Annex B String.prototype HTML methods that works as far down as ES3

License

Notifications You must be signed in to change notification settings

es-shims/es-string-html-methods

Repository files navigation

es-string-html-methods Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

An ES-spec-compliant shim/polyfill/replacement for the Annex B String.prototype HTML methods that works as far down as ES3

This package implements the es-shim API “multi” interface. It works in an ES3-supported environment and complies with the spec.

Because the String.prototype HTML methods depend on a receiver (the this value), the main export in each subdirectory takes the string to operate on as the first argument.

The main export of the package itself is simply an array of the available directory names. It’s sole intended use is for build tooling and testing.

Supported methods

Getting started

npm install --save es-string-html-methods

Usage/Examples

var blink = require('es-string-html-methods/blink');
var link = require('es-string-html-methods/link');
var assert = require('assert');

assert.equal(
	blink('a'),
	'<blink>a</blink>'
);
assert.equal(
	link('a', 'b'),
	'<a href="b">a</a>'
);
require('./auto'); // shim all of the methods

require('./anchor/auto'); // shim the “anchor” method

Tests

Simply clone the repo, npm install, and run npm test