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

html-to-vdom

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-to-vdom - npm Package Compare versions

Comparing version 0.5.1 to 0.5.2

12

lib/htmlparser-to-vdom.js

@@ -17,2 +17,11 @@ var decode = require('ent').decode;

// Transform a data attribute name to a valid dataset key name
// (See https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement.dataset)
var dataAttributeToDatasetKey = function dataAttributeToDatasetKey (name) {
var unprefixed = name.slice(prefixLength);
return unprefixed.replace(/\-([a-z])/g, function (m, charAfterHyphen) {
return charAfterHyphen.toUpperCase();
});
};
var getDataset = function getDataset (tag) {

@@ -32,4 +41,3 @@ var attributes = tag.attribs;

}
var unprefixed = name.slice(prefixLength);
dataset[unprefixed] = value;
dataset[dataAttributeToDatasetKey(name)] = value;
});

@@ -36,0 +44,0 @@

2

package.json
{
"name": "html-to-vdom",
"version": "0.5.1",
"version": "0.5.2",
"description": "Converts html into a vtree",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -74,1 +74,2 @@ html-to-vdom [![Build Status](https://travis-ci.org/TimBeyer/html-to-vdom.svg?branch=master)](https://travis-ci.org/TimBeyer/html-to-vdom)

* [@jsyang](https://github.com/jsyang) for removing the `lodash` dependency for a leaner build and [improved performance](http://jsperf.com/html-to-vdom-lodash-vs-native)
* [@bregenspan](https://github.com/bregenspan) for making the dataset conversion standards-compliant

@@ -135,2 +135,16 @@ var VNode = require('virtual-dom/vnode/vnode');

it('converts a single hyphenated data attribute correctly', function () {
var html = '<div data-test-data="foobar"></div>';
var converted = convertHTML(html);
should.exist(converted.properties.dataset.testData);
converted.properties.dataset.testData.should.eql('foobar');
should.exist(converted.properties['data-test-data']);
converted.properties['data-test-data'].should.eql('foobar');
});
it('converts multiple data attributes correctly', function () {

@@ -137,0 +151,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