Socket
Socket
Sign inDemoInstall

snabbdom-virtualize

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

snabbdom-virtualize - npm Package Compare versions

Comparing version 0.6.0 to 0.7.0

4

lib/nodes.js

@@ -108,3 +108,5 @@ 'use strict';

className.split(' ').forEach(function (className) {
classes[className] = true;
if (className.trim().length) {
classes[className.trim()] = true;
}
});

@@ -111,0 +113,0 @@ }

@@ -31,3 +31,3 @@ 'use strict';

// Regex for matching HTML entities.
var entityRegex = new RegExp('&[a-z0-9]+;', 'gi');
var entityRegex = new RegExp('&[a-z0-9#]+;', 'gi');
// Element for setting innerHTML for transforming entities.

@@ -34,0 +34,0 @@ var el = null;

{
"name": "snabbdom-virtualize",
"version": "0.6.0",
"version": "0.7.0",
"description": "Library for turning strings and DOM nodes into virtual DOM nodes compatible with snabbdom.",

@@ -19,3 +19,3 @@ "author": {

"watch": "npm run build -- --watch",
"test": "npm run build && karma start test/karma.conf.js && mocha test/nodejs_tests.js"
"test": "npm run build && mocha test/nodejs_tests.js && karma start test/karma.conf.js"
},

@@ -42,3 +42,3 @@ "main": "lib/index.js",

"sinon-chai": "^2.8.0",
"snabbdom": "~0",
"snabbdom": "~0.6.6",
"socket.io": "1.4.6",

@@ -48,7 +48,7 @@ "webpack": "^1.12.12"

"peerDependencies": {
"snabbdom": "~0"
"snabbdom": "~0.6.6"
},
"dependencies": {
"html-parse-stringify2": "^1.2.1"
"html-parse-stringify2": "^2"
}
}

@@ -5,4 +5,12 @@ # snabbdom-virtualize [![Build Status](https://travis-ci.org/appcues/snabbdom-virtualize.svg?branch=master)](https://travis-ci.org/appcues/snabbdom-virtualize)

### Usage
## API
### `virtualize(nodes, options)`
* `nodes: Element|String` - Either a DOM `Element` or a string of HTML to turn into a set of virtual DOM nodes.
* `options: Object` - A hash of options to pass into the virtualize call. Available options are currently:
* `context: Document` - An alternative DOM document to use (default is `window.document`).
* `hooks: Object` - An object specifying hooks to call during the virtualization process. See the [hooks](#hooks) section below.
## Usage
Add it to your application with

@@ -38,5 +46,17 @@

// String
let vnode = virtualize('<div>Click <a href="http://example.com">here</a>');
let vnode = virtualize('<div>Click <a href="http://example.com">here</a></div>');
```
#### Specifying a different document
You can specify a different DOM document (other than the default `window.document` in a browser) by passing a `context` option into your calls to `virtualize`. This will allow for usage in a server-side setting, where there is no browser. One option is to use `jsdom` to create a DOM document that can be used:
```javascript
const virtualize = require('snabbdom-virtualize').default;
const jsdom = require('jsdom').jsdom;
virtualizeString('<div>Click <a href="http://example.com">here</a></div>', {
context: jsdom('<html></html>')
});
```
#### Using modules à la carte

@@ -66,3 +86,3 @@

let vnode = virtualize('<div>Click <a href="http://example.com">here</a>');
let vnode = virtualize('<div>Click <a href="http://example.com">here</a></div>');

@@ -69,0 +89,0 @@ ```

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