dom-serialize
Advanced tools
Comparing version 2.1.0 to 2.2.0
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="<>"&"', 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="<>"&"', serialize.serializeAttribute(d.attributes[0], { named: false })); | ||
}); | ||
}); | ||
describe('serializeText()', function () { | ||
it('should serialize a TextNode instance', function () { | ||
node = document.createTextNode('<b>&'); | ||
assert.equal('<b>&', serialize.serializeText(node)); | ||
}); | ||
it('should allow an "options" object to be passed in', function () { | ||
node = document.createTextNode('<b>&'); | ||
assert.equal('<b>&', serialize.serializeText(node, { named: false })); | ||
}); | ||
}); | ||
describe('"serialize" event', function () { | ||
@@ -134,0 +164,0 @@ |
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
25104
505
4
+ Addedextend@~2.0.0
+ Addedextend@2.0.2(transitive)