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

min-document

Package Overview
Dependencies
Maintainers
1
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 0.2.6 to 0.2.7

30

index.js

@@ -70,2 +70,4 @@ function DOMText(value) {

var body = createElement("body")
module.exports = Document()

@@ -75,5 +77,7 @@

return {
body: body,
createTextNode: createTextNode,
createElement: createElement,
createDocumentFragment: createDocumentFragment
createDocumentFragment: createDocumentFragment,
getElementById: getElementById
}

@@ -94,2 +98,26 @@ }

/*
* getElementById returns the Element whose ID is given by elementId.
* If no such element exists, returns null.
* Behavior is not defined if more than one element has this ID.
*/
function recursive_getElementById(id, elem) {
if (""+elem.id === ""+id) return elem
var arr = elem.childNodes
, result = null
if (arr) {
for (var i = 0, len = arr.length; !result && i < len; i++) {
result = recursive_getElementById(id, arr[i])
}
}
return result
}
function getElementById(id) {
return recursive_getElementById(id, body)
}
function _Element_toString() {

@@ -96,0 +124,0 @@ var strings = []

2

package.json
{
"name": "min-document",
"version": "0.2.6",
"version": "0.2.7",
"description": "A minimal DOM implementation",

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

@@ -53,1 +53,34 @@ var test = require("tape")

test("can getElementById", function (assert) {
function append_div(id, parent) {
var div = document.createElement("div")
div.id = id
parent.appendChild(div)
return div
}
var div1 = append_div(1, document.body)
var div2 = append_div(2, document.body)
var div3 = append_div(3, document.body)
var div11 = append_div(11, div1)
var div12 = append_div(12, div1)
var div21 = append_div(21, div2)
var div22 = append_div(22, div2)
var div221 = append_div(221, div22)
var div222 = append_div(222, div22)
assert.equal(document.getElementById(1), div1)
assert.equal(document.getElementById("2"), div2)
assert.equal(document.getElementById(3), div3)
assert.equal(document.getElementById(11), div11)
assert.equal(document.getElementById(12), div12)
assert.equal(document.getElementById(21), div21)
assert.equal(document.getElementById(22), div22)
assert.equal(document.getElementById(221), div221)
assert.equal(document.getElementById(222), div222)
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