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

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.3.0 to 2.4.0

document.js

3

dom-element.js

@@ -7,3 +7,3 @@ var dispatchEvent = require("./event/dispatch-event.js")

function DOMElement(tagName) {
function DOMElement(tagName, owner) {
if (!(this instanceof DOMElement)) {

@@ -19,2 +19,3 @@ return new DOMElement(tagName)

this.style = {}
this.ownerDocument = owner || null;
}

@@ -21,0 +22,0 @@

@@ -5,3 +5,3 @@ var DOMElement = require("./dom-element.js")

function DocumentFragment() {
function DocumentFragment(owner) {
if (!(this instanceof DocumentFragment)) {

@@ -13,2 +13,3 @@ return new DocumentFragment()

this.parentNode = null
this.ownerDocument = owner || null
}

@@ -15,0 +16,0 @@

module.exports = DOMText
function DOMText(value) {
function DOMText(value, owner) {
if (!(this instanceof DOMText)) {

@@ -10,2 +10,3 @@ return new DOMText(value)

this.length = this.data.length
this.ownerDocument = owner || null
}

@@ -26,2 +27,2 @@

this.length = this.data.length
}
}

@@ -1,77 +0,3 @@

var DOMText = require("./dom-text.js")
var DOMElement = require("./dom-element.js")
var DocumentFragment = require("./dom-fragment.js")
var Event = require("./event.js")
var Document = require('./document.js');
var body = createElement("body")
var documentElement = createElement("html")
documentElement.appendChild(body)
module.exports = Document()
function Document() {
return {
body: body,
documentElement: documentElement,
createTextNode: createTextNode,
createElement: createElement,
createDocumentFragment: createDocumentFragment,
createEvent: createEvent,
getElementById: getElementById,
Document: Document,
Text: DOMText,
Element: DOMElement,
DocumentFragment: DocumentFragment
}
}
function ownerDocument(that, node) {
node.ownerDocument = that
return node
}
function createTextNode(value) {
return ownerDocument(this, new DOMText(value))
}
function createElement(tagName) {
return ownerDocument(this, new DOMElement(tagName))
}
function createDocumentFragment() {
return ownerDocument(this, new DocumentFragment())
}
function createEvent(family) {
return new Event(family)
}
/*
* 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 getElementById(id, parent) {
if (!parent) {
parent = body
}
if (String(parent.id) === String(id)) {
return parent
}
var arr = parent.childNodes
var result = null
if (!arr) {
return result
}
for (var i = 0, len = arr.length; !result && i < len; i++) {
result = getElementById(id, arr[i])
}
return result
}
module.exports = new Document();
{
"name": "min-document",
"version": "2.3.0",
"version": "2.4.0",
"description": "A minimal DOM implementation",

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

@@ -6,4 +6,4 @@ module.exports = serializeElement

strings.push("<" + elem.tagName + properties(elem) +
datasetify(elem) + ">")
strings.push("<" + elem.tagName.toLowerCase() +
properties(elem) + datasetify(elem) + ">")

@@ -18,3 +18,3 @@ if (elem.textContent) {

strings.push("</" + elem.tagName + ">")
strings.push("</" + elem.tagName.toLowerCase() + ">")

@@ -21,0 +21,0 @@ return strings.join("\n")

Sorry, the diff of this file is not supported yet

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