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.4 to 0.5.5

.editorconfig

8

lib/htmlparser-to-vdom.js

@@ -61,7 +61,9 @@ var decode = require('ent').decode;

convert: function (node, getVNodeKey) {
if (node.type === 'tag') {
if (node.type === 'tag' || node.type === 'script' || node.type === 'style') {
return converter.convertTag(node, getVNodeKey);
}
else if (node.type === 'text') {
} else if (node.type === 'text') {
return new VText(decode(node.data));
} else {
// converting an unsupported node, return an empty text node instead.
return new VText('');
}

@@ -68,0 +70,0 @@ },

{
"name": "html-to-vdom",
"version": "0.5.4",
"version": "0.5.5",
"description": "Converts html into a vtree",

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

@@ -75,1 +75,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)

* [@bregenspan](https://github.com/bregenspan) for making the dataset conversion standards-compliant
* [@jesseditson](https://github.com/jesseditson) for adding `<script>` and `<style>` tag support

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

});
describe('when converting HTML containing a script tag', function () {
it('converts to a virtualdom node', function () {
var html = '<div><script src="foo.js">alert("bar!");</script></div>';
var converted = convertHTML(html);
var script = converted.children[0];
should.exist(script);
script.tagName.should.eql('script');
script.children.length.should.eql(1);
script.children[0].text.should.eql('alert("bar!");');
});
});
describe('when converting HTML containing a style tag', function () {
it('converts to a virtualdom node', function () {
var html = '<div><style>h1 {color:red;} p {color:blue;} </style></div>';
var converted = convertHTML(html);
var script = converted.children[0];
should.exist(script);
script.tagName.should.eql('style');
script.children.length.should.eql(1);
script.children[0].text.should.eql('h1 {color:red;} p {color:blue;} ');
});
});
describe('when converting HTML containing CDATA', function () {
it('returns an empty string instead (cdata is unsupported)', function () {
var html = '<![CDATA[ Within this Character Data block I can\
use double dashes as much as I want (along with <, &, \', and ")\
*and* %MyParamEntity; will be expanded to the text\
"Has been expanded" ... however, I can\'t use\
the CEND sequence (if I need to use it I must escape one of the\
brackets or the greater-than sign).\
]]>';
var converted = convertHTML(html);
converted.text.should.eql('');
});
});
describe('when converting HTML containing a directive', function () {
it('returns an empty string instead (directives are unsupported)', function () {
var html = '<!DOCTYPE html>';
var converted = convertHTML(html);
converted.text.should.eql('');
});
});
describe('when converting HTML containing a comment', function () {
it('returns an empty string instead (comments are unsupported)', function () {
var html = '<div><!-- some comment --></div>';
var converted = convertHTML(html);
var comment = converted.children[0];
comment.text.should.eql('');
});
});
});
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