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

dom-serialize

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dom-serialize - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

5

History.md
2.2.0 / 2015-02-13
==================
* add support for passing `encode()` options in to `serializeAttribute()` and `serializeTextNode()`
2.1.0 / 2015-02-10

@@ -3,0 +8,0 @@ ==================

13

index.js

@@ -6,2 +6,3 @@

var extend = require('extend');
var encode = require('ent/encode');

@@ -129,6 +130,6 @@ var CustomEvent = require('custom-event');

function serializeAttribute (node) {
return node.name + '="' + encode(node.value, {
function serializeAttribute (node, opts) {
return node.name + '="' + encode(node.value, extend({
named: true
}) + '"';
}, opts)) + '"';
}

@@ -169,7 +170,7 @@

function serializeText (node) {
return encode(node.nodeValue, {
function serializeText (node, opts) {
return encode(node.nodeValue, extend({
named: true,
special: { '<': true, '>': true, '&': true }
});
}, opts));
}

@@ -176,0 +177,0 @@

{
"name": "dom-serialize",
"version": "2.1.0",
"version": "2.2.0",
"description": "Serializes any DOM node into a String",

@@ -29,2 +29,3 @@ "main": "index.js",

"ent": "~2.2.0",
"extend": "~2.0.0",
"void-elements": "~1.0.0"

@@ -31,0 +32,0 @@ },

@@ -132,2 +132,32 @@

describe('serializeText()', function () {
it('should serialize an Attribute node', function () {
var d = document.createElement('div');
d.setAttribute('foo', '<>"&');
assert.equal('foo="&lt;&gt;&quot;&amp;"', serialize.serializeAttribute(d.attributes[0]));
});
it('should allow an "options" object to be passed in', function () {
var d = document.createElement('div');
d.setAttribute('foo', '<>"&');
assert.equal('foo="&#60;&#62;&#34;&#38;"', serialize.serializeAttribute(d.attributes[0], { named: false }));
});
});
describe('serializeText()', function () {
it('should serialize a TextNode instance', function () {
node = document.createTextNode('<b>&');
assert.equal('&lt;b&gt;&amp;', serialize.serializeText(node));
});
it('should allow an "options" object to be passed in', function () {
node = document.createTextNode('<b>&');
assert.equal('&#60;b&#62;&#38;', serialize.serializeText(node, { named: false }));
});
});
describe('"serialize" event', function () {

@@ -134,0 +164,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