Socket
Socket
Sign inDemoInstall

mithril-node-render

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mithril-node-render - npm Package Compare versions

Comparing version 0.1.8 to 0.2.0

29

index.js

@@ -15,2 +15,13 @@ 'use strict';

// shameless stolen from https://github.com/punkave/sanitize-html
function escapeHtml(s) {
if (s === 'undefined') {
s = '';
}
if (typeof(s) !== 'string') {
s = s + '';
}
return s.replace(/\&/g, '&amp;').replace(/</g, '&lt;').replace(/\>/g, '&gt;').replace(/\"/g, '&quot;');
}
function createAttrString(attrs) {

@@ -41,11 +52,2 @@ if (!attrs || !Object.keys(attrs).length) {

function createTrustedContent(view) {
return Object.keys(view).map(function(key) {
if (key === '$trusted') {
return '';
}
return view[key];
}).join('');
}
function createChildrenContent(view) {

@@ -61,3 +63,8 @@ if(isArray(view.children) && !view.children.length) {

var type = typeof view;
if (type === 'string' || type === 'number' || type === 'boolean') {
if (type === 'string') {
return escapeHtml(view);
}
if(type === 'number' || type === 'boolean') {
return view;

@@ -75,3 +82,3 @@ }

if (view.$trusted) {
return createTrustedContent(view);
return '' + view;
}

@@ -78,0 +85,0 @@ var children = createChildrenContent(view);

{
"name": "mithril-node-render",
"version": "0.1.8",
"version": "0.2.0",
"description": "Node rending of mithril views",

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

@@ -21,2 +21,3 @@ mithril-node-render

[Blog post](https://gist.github.com/StephanHoyer/bddccd9e159828867d2a) about isomorphic mithril applications.
* [Blog post](https://gist.github.com/StephanHoyer/bddccd9e159828867d2a) about isomorphic mithril applications
* [Usage Example](https://github.com/StephanHoyer/mithril-isomorphic-example/blob/master/README.md)

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

t.equal(render(m('div', { a: false})), '<div></div>');
t.equal(render(m('div', m.trust('<foo></foo>'))), '<div><foo></foo></div>');
t.equal(render(m('div', '<foo></foo>')), '<div>&lt;foo&gt;&lt;/foo&gt;</div>');
t.end();
});
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