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

min-documentx

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

min-documentx - npm Package Compare versions

Comparing version 2.17.2 to 2.19.0

14

dom-element.js

@@ -19,2 +19,3 @@ var domWalk = require("dom-walk")

this.tagName = ns === htmlns ? String(tagName).toUpperCase() : tagName
this.nodeName = this.tagName
this.className = ""

@@ -107,4 +108,9 @@ this.dataset = {}

}
var attributes = this._attributes[namespace] || (this._attributes[namespace] = {})
attributes[localName] = {value: value, prefix: prefix}
if (this.tagName === 'INPUT' && name === 'type') {
this.type = value;
}
else {
var attributes = this._attributes[namespace] || (this._attributes[namespace] = {})
attributes[localName] = {value: value, prefix: prefix}
}
}

@@ -116,6 +122,8 @@

var value = attributes && attributes[name] && attributes[name].value
if (this.tagName === 'INPUT' && name === 'type') {
return this.type;
}
if (typeof value !== "string") {
return null
}
return value

@@ -122,0 +130,0 @@ }

@@ -15,2 +15,3 @@ module.exports = DOMText

DOMText.prototype.nodeType = 3
DOMText.prototype.nodeName = "#text"

@@ -17,0 +18,0 @@ DOMText.prototype.toString = function _Text_toString() {

{
"name": "min-documentx",
"version": "2.17.2",
"version": "2.19.0",
"description": "A minimal DOM implementation",

@@ -5,0 +5,0 @@ "keywords": [],

module.exports = serializeNode
var voidElements = /area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr/i;
var hasOwn = Object.prototype.hasOwnProperty;
var voidElements = ["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"];

@@ -28,3 +27,3 @@ function serializeNode(node) {

if (voidElements.test(tagname)) {
if (voidElements.indexOf(tagname) > -1) {
strings.push(" />")

@@ -51,3 +50,3 @@ } else {

if (key === "style" && Object.keys(elem.style).length > 0) {
if (key === "style" && (type === "string" && elem[key] || Object.keys(elem.style).length > 0)) {
return true

@@ -57,3 +56,3 @@ }

return elem.hasOwnProperty(key) &&
(type === "string" || (type === "boolean" && elem[key]) || type === "number") &&
(type === "string" || type === "boolean" || type === "number") &&
key !== "nodeName" && key !== "className" && key !== "tagName" &&

@@ -64,2 +63,3 @@ key !== "textContent" && key !== "innerText" && key !== "namespaceURI" && key !== "innerHTML"

function stylify(styles) {
if (typeof styles === 'string') return styles
var attr = ""

@@ -97,3 +97,3 @@ Object.keys(styles).forEach(function (key) {

attributes.push(name + "=" + "\"" + escapeAttributeValue(String(value)) + "\"")
attributes.push(name + "=" + "\"" + escapeAttributeValue(value) + "\"")
})

@@ -107,3 +107,3 @@

for (var key in elem) {
if (hasOwn.call(elem, key) && isProperty(elem, key)) {
if (isProperty(elem, key)) {
props.push({ name: key, value: elem[key] })

@@ -128,3 +128,11 @@ }

function escapeText(str) {
function escapeText(s) {
var str = '';
if (typeof(s) === 'string') {
str = s;
} else if (s) {
str = s.toString();
}
return str

@@ -131,0 +139,0 @@ .replace(/&/g, "&")

@@ -329,3 +329,3 @@ var test = require("tape")

var elem = document.createElement("input")
assert.equal(elem.type, "text");
assert.equal(elem.getAttribute("type"), "text");
assert.equal(elemString(elem), "<input type=\"text\" />")

@@ -335,2 +335,10 @@ assert.end()

test("input type=text can be overridden", function (assert) {
var elem = document.createElement("input")
elem.setAttribute("type", "hidden")
assert.equal(elem.getAttribute("type"), "hidden");
assert.equal(elemString(elem), "<input type=\"hidden\" />")
assert.end()
})
test("can set and get attributes", function (assert) {

@@ -337,0 +345,0 @@ var elem = document.createElement("div")

@@ -159,2 +159,10 @@ var test = require("tape")

test("can serialize style as a string", function(assert) {
var div = document.createElement("div")
div.setAttribute('style', 'display: none')
assert.equal(div.toString(), "<div style=\"display: none\"></div>")
cleanup()
assert.end()
})
test("can serialize text nodes", function(assert) {

@@ -193,2 +201,21 @@ var div = document.createElement("div")

})
test("can handle non string attribute values", function(assert) {
var div = document.createElement("div")
div.setAttribute("data-number", 100)
div.setAttribute("data-boolean", true)
div.setAttribute("data-null", null)
assert.equal(div.toString(), '<div data-number="100" data-boolean="true" data-null=""></div>')
cleanup()
assert.end()
})
test("can serialize textarea correctly", function(assert) {
var input = document.createElement("textarea")
input.setAttribute("name", "comment")
input.innerHTML = "user input here"
assert.equal(input.toString(), '<textarea name="comment">user input here</textarea>')
cleanup()
assert.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