Socket
Socket
Sign inDemoInstall

min-document

Package Overview
Dependencies
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

min-document - npm Package Compare versions

Comparing version 2.17.0 to 2.18.0

1

document.js

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

proto.getElementsByTagName = DOMElement.prototype.getElementsByTagName
proto.contains = DOMElement.prototype.contains

@@ -70,0 +71,0 @@ proto.removeEventListener = removeEventListener

20

dom-element.js

@@ -99,6 +99,11 @@ var domWalk = require("dom-walk")

function _Element_setAttributeNS(namespace, name, value) {
var prefix = null
var localName = name
var colonPosition = name.indexOf(":")
var localName = colonPosition > -1 ? name.substr(colonPosition + 1) : name
if (colonPosition > -1) {
prefix = name.substr(0, colonPosition)
localName = name.substr(colonPosition + 1)
}
var attributes = this._attributes[namespace] || (this._attributes[namespace] = {})
attributes[localName] = value
attributes[localName] = {value: value, prefix: prefix}
}

@@ -109,7 +114,8 @@

var attributes = this._attributes[namespace];
if (!(attributes && typeof attributes[name] === "string")) {
var value = attributes && attributes[name] && attributes[name].value
if (typeof value !== "string") {
return null
}
return attributes[name]
return value
}

@@ -192,1 +198,7 @@

}
DOMElement.prototype.contains = function _Element_contains(element) {
return domWalk(this, function (node) {
return element === node
}) || false
}
{
"name": "min-document",
"version": "2.17.0",
"version": "2.18.0",
"description": "A minimal DOM implementation",

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

@@ -36,2 +36,4 @@ module.exports = serializeNode

strings.push(escapeText(elem.textContent || elem.innerText))
} else if (elem.innerHTML) {
strings.push(elem.innerHTML)
}

@@ -55,3 +57,3 @@

key !== "nodeName" && key !== "className" && key !== "tagName" &&
key !== "textContent" && key !== "innerText" && key !== "namespaceURI"
key !== "textContent" && key !== "innerText" && key !== "namespaceURI" && key !== "innerHTML"
}

@@ -63,2 +65,5 @@

var value = styles[key]
key = key.replace(/[A-Z]/g, function(c) {
return "-" + c.toLowerCase();
})
attr += key + ":" + value + ";"

@@ -106,4 +111,5 @@ })

for (var attribute in elem._attributes[ns]) {
var name = (ns !== "null" ? ns + ":" : "") + attribute
props.push({ name: name, value: elem._attributes[ns][attribute] })
var prop = elem._attributes[ns][attribute]
var name = (prop.prefix ? prop.prefix + ":" : "") + attribute
props.push({ name: name, value: prop.value })
}

@@ -110,0 +116,0 @@ }

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

var cleanup = require('./cleanup')(document)
var Event = require('../Event');
var Event = require('../event');

@@ -378,2 +378,3 @@ test("document is a Document", function (assert) {

assert.equal(elem.getAttributeNS(ns, "myattr"), "the value")
assert.equal(elemString(elem), '<div myns:myattr="the value"></div>')
elem.removeAttributeNS(ns, "myattr")

@@ -481,2 +482,13 @@ assert.equal(elem.getAttributeNS(ns, "myattr"), blankAttributeNS())

test("can check if it contains an element", function(assert) {
var el = document.createElement("div")
document.body.appendChild(el)
assert.equals(document.contains(document.body), true)
assert.equals(document.contains(el), true)
cleanup()
assert.end()
})
test("can do events", function (assert) {

@@ -483,0 +495,0 @@ var x = 1

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

test("does not serialize innerHTML as an attribute", function(assert) {
var div = document.createElement("div")
div.innerHTML = "Test <img />"
assert.equal(div.toString(), "<div>Test <img /></div>")
cleanup()
assert.end()
})
test("can getElementsByTagName", function(assert) {

@@ -144,2 +152,10 @@ var parent = document.createElement("div")

test("can serialize style property", function(assert) {
var div = document.createElement("div")
div.style.fontSize = "16px"
assert.equal(div.toString(), "<div style=\"font-size:16px;\"></div>")
cleanup();
assert.end()
})
test("can serialize text nodes", function(assert) {

@@ -160,2 +176,20 @@ var div = document.createElement("div")

})
test("can check if an element contains another", function(assert) {
var parent = document.createElement("div")
var sibling = document.createElement("div")
var child1 = document.createElement("div")
var child2 = document.createElement("div")
child1.appendChild(child2)
parent.appendChild(child1)
assert.equal(parent.contains(parent), true)
assert.equal(parent.contains(sibling), false)
assert.equal(parent.contains(child1), true)
assert.equal(parent.contains(child2), true)
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