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.3.0 to 0.4.0

lib/event-listeners.js

8

package.json
{
"name": "snabbdom-virtualize",
"version": "0.3.0",
"version": "0.4.0",
"description": "Library for turning strings and DOM nodes into virtual DOM nodes compatible with snabbdom.",

@@ -17,7 +17,7 @@ "author": {

"prepublish": "npm run build",
"build": "webpack --config webpack.config.js",
"watch": "webpack --watch --config webpack.config.js",
"build": "babel src -d lib",
"watch": "npm run build -- --watch",
"test": "karma start test/karma.conf.js"
},
"main": "index.js",
"main": "lib/index.js",
"devDependencies": {

@@ -24,0 +24,0 @@ "babel-cli": "^6.3.17",

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

// Require.
var virtualize = require('snabbdom-virtualize');
let virtualize = require('snabbdom-virtualize');
```

@@ -27,5 +27,5 @@

// Actual DOM nodes
var topNode = document.createElement('div');
var textNode = document.createTextNode('Click ');
var linkNode = document.createElement('a');
let topNode = document.createElement('div');
let textNode = document.createTextNode('Click ');
let linkNode = document.createElement('a');
linkNode.setAttribute('href', 'http://example.com');

@@ -35,8 +35,37 @@ linkNode.textContent = 'here';

topNode.appendChild(linkNode);
var vnode = virtualize(topNode);
let vnode = virtualize(topNode);
// String
var vnode = virtualize('<div>Click <a href="http://example.com">here</a>');
let vnode = virtualize('<div>Click <a href="http://example.com">here</a>');
```
#### Using modules à la carte
If you'd prefer to import just the function for virtualizing DOM nodes or just
the function for virtualizing HTML strings, you're in luck. Just import
`snabbdom-virtualize/nodes` or `snabbdom-virtualize/strings` and use in the
same way:
```javascript
// DOM nodes.
import virtualize from 'snabbdom-virtualize/nodes';
let topNode = document.createElement('div');
let textNode = document.createTextNode('Click ');
let linkNode = document.createElement('a');
linkNode.setAttribute('href', 'http://example.com');
linkNode.textContent = 'here';
topNode.appendChild(textNode);
topNode.appendChild(linkNode);
let vnode = virtualize(topNode);
// HTML strings.
import virtualize from 'snabbdom-virtualize/strings';
let vnode = virtualize('<div>Click <a href="http://example.com">here</a>');
```
### Project setup

@@ -51,3 +80,3 @@

This will output a compiled `index.js` file in the root directory.
This will output compiled files in the `lib` directory.

@@ -54,0 +83,0 @@ ### Tests

Sorry, the diff of this file is not supported yet

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