html-to-vdom
Advanced tools
Comparing version 0.5.0 to 0.5.1
var createConverter = require('./htmlparser-to-vdom'); | ||
var parseHTML = require('./parse-html'); | ||
var _ = require('lodash'); | ||
@@ -8,3 +7,3 @@ module.exports = function initializeHtmlToVdom (VTree, VText) { | ||
return function convertHTML(options, html) { | ||
var noOptions = _.isUndefined(html) && _.isString(options); | ||
var noOptions = typeof html === 'undefined' && typeof options === 'string'; | ||
var hasOptions = !noOptions; | ||
@@ -11,0 +10,0 @@ |
var decode = require('ent').decode; | ||
var _ = require('lodash'); | ||
@@ -20,3 +19,5 @@ var prefixLength = ('data-').length; | ||
var attributes = tag.attribs; | ||
if (_.isEmpty(attributes)) { | ||
if (typeof attributes === 'undefined' || | ||
attributes === null || | ||
Object.keys(attributes).length === 0) { | ||
return {}; | ||
@@ -26,3 +27,4 @@ } | ||
var dataset = {}; | ||
_.each(attributes, function (value, name) { | ||
Object.keys(attributes).forEach(function (name) { | ||
var value = attributes[name]; | ||
if (!(/^data-/).test(name)) { | ||
@@ -40,3 +42,3 @@ return; | ||
var attributes = input.split(';'); | ||
var styles = _.reduce(attributes, function(object, attribute) { | ||
var styles = attributes.reduce(function(object, attribute){ | ||
var entry = attribute.split(/:(.+)/); | ||
@@ -47,3 +49,3 @@ if (entry[0] && entry[1]) { | ||
return object; | ||
}, {}); | ||
},{}); | ||
return styles; | ||
@@ -69,4 +71,6 @@ }; | ||
}; | ||
_.each(tag.attribs, function (value, name) { | ||
Object.keys(tag.attribs).forEach(function (name) { | ||
var value = tag.attribs[name]; | ||
if (attributesToRename[name]) { | ||
@@ -91,3 +95,3 @@ attributes[attributesToRename[name]] = value; | ||
var children = _.map(tag.children, function(node) { | ||
var children = Array.prototype.map.call(tag.children || [], function(node) { | ||
return converter.convert(node, getVNodeKey); | ||
@@ -94,0 +98,0 @@ }); |
{ | ||
"name": "html-to-vdom", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "Converts html into a vtree", | ||
@@ -21,4 +21,3 @@ "main": "index.js", | ||
"ent": "^2.0.0", | ||
"htmlparser2": "^3.8.2", | ||
"lodash": "^2.4.1" | ||
"htmlparser2": "^3.8.2" | ||
}, | ||
@@ -25,0 +24,0 @@ "devDependencies": { |
@@ -13,2 +13,4 @@ html-to-vdom [![Build Status](https://travis-ci.org/TimBeyer/html-to-vdom.svg?branch=master)](https://travis-ci.org/TimBeyer/html-to-vdom) | ||
As of v0.5.1, `html-to-vdom` no longer supports browsers without a full ES5 implementation. | ||
As of v0.3.0, the VNode and VText classes need to be passed in during library initialization from the `virtual-dom` module you are using. | ||
@@ -68,4 +70,6 @@ This is to reduce incompatibilties you might have due to depending on a different version of `virtual-dom` than the one this library would use. | ||
Thanks to [@mattferrin](https://github.com/mattferrin) for noticing that promises could be removed from the API and contributing a PR to do so. | ||
Thanks to [@tiagorg](https://github.com/tiagorg) for contributing a PR for style attribute parsing. | ||
Thanks to [@dariusriggins](https://github.com/dariusriggins) for adding VNode key support. | ||
Thanks to: | ||
* [@mattferrin](https://github.com/mattferrin) for noticing that promises could be removed from the API and contributing a PR to do so | ||
* [@tiagorg](https://github.com/tiagorg) for contributing a PR for style attribute parsing | ||
* [@dariusriggins](https://github.com/dariusriggins) for adding VNode key support | ||
* [@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) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21446
2
13
335
74
- Removedlodash@^2.4.1
- Removedlodash@2.4.2(transitive)