New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

linkedom

Package Overview
Dependencies
Maintainers
1
Versions
214
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

linkedom - npm Package Compare versions

Comparing version 0.1.17 to 0.1.18

53

cjs/document.js

@@ -7,2 +7,3 @@ 'use strict';

const {NonElementParentNode, ParentNode} = require('./mixins.js');
const {Event, CustomEvent} = require('./interfaces.js');

@@ -19,2 +20,4 @@ const {Attr} = require('./attr.js');

const {create, defineProperties} = Object;
/**

@@ -38,3 +41,9 @@ * @implements globalThis.Document

get defaultView() { return globalThis; }
// <NonElementParentNode>
/**
* @param {string} id
* @returns {Element?}
*/
getElementById(id) {

@@ -70,2 +79,5 @@ const {root} = this;

/**
* This throws on Document instances.
*/
prepend(...nodes) {

@@ -75,2 +87,5 @@ throw new Error('Cannot have more than one Element child of a Document');

/**
* This throws on Document instances.
*/
append(...nodes) {

@@ -80,2 +95,5 @@ throw new Error('Cannot have more than one Element child of a Document');

/**
* This throws on Document instances.
*/
replaceChildren(...nodes) {

@@ -104,2 +122,6 @@ throw new Error('Cannot have more than one Element child of a Document');

/**
* @param {string} name
* @returns {Attr}
*/
createAttribute(name) {

@@ -134,2 +156,25 @@ return new Attr(this, name, '');

/**
* @deprecated
* @param {"Event"|"CustomEvent"} name
* @returns {Event|CustomEvent}
*/
createEvent(name) {
const event = create(name === 'Event' ? new Event('') : new CustomEvent(''));
event.initEvent = event.initCustomEvent = (
type,
canBubble = false,
cancelable = false,
detail
) => {
defineProperties(event, {
type: {value: type},
canBubble: {value: canBubble},
cancelable: {value: cancelable},
detail: {value: detail}
});
};
return event;
}
/**
* @param {string} textContent

@@ -161,2 +206,10 @@ */

/**
* @param {Node} node
* @param {boolean?} deep
*/
importNode(node, deep = false) {
return node.cloneNode(deep);
}
/**
* @param {string} name

@@ -163,0 +216,0 @@ * @returns {NodeList}

'use strict';
const {getEnd} = require('./utils.js');
const {Document} = require('./document.js');

@@ -21,3 +22,54 @@

}
/**
* @type HTMLAllCollection
*/
get all() {
const all = [this.root];
let {_next, _end} = all[0];
while (_next !== _end) {
all.push(_next);
_next = getEnd(_next)._next;
}
return all;
}
/**
* @type HTMLHeadElement
*/
get head() {
let {firstElementChild} = this.root;
// whatever
if (!firstElementChild) {
firstElementChild = this.createElement('head');
this.root.prepend(firstElementChild);
}
return firstElementChild;
}
/**
* @type HTMLBodyElement
*/
get body() {
let {nextElementSibling} = this.head;
// whatever
if (!nextElementSibling) {
nextElementSibling = this.createElement('body');
this.head.after(nextElementSibling);
}
return nextElementSibling;
}
/**
* @type HTMLTitleElement
*/
get title() {
let title = this.head.getElementsByTagName('title').shift();
if (!title) {
title = this.createElement('title');
this.head.prepend(title);
}
return title;
}
}
exports.HTMLDocument = HTMLDocument

@@ -6,2 +6,3 @@ import {DOCUMENT_NODE} from './constants.js';

import {NonElementParentNode, ParentNode} from './mixins.js';
import {Event, CustomEvent} from './interfaces.js';

@@ -18,2 +19,4 @@ import {Attr} from './attr.js';

const {create, defineProperties} = Object;
/**

@@ -37,3 +40,9 @@ * @implements globalThis.Document

get defaultView() { return globalThis; }
// <NonElementParentNode>
/**
* @param {string} id
* @returns {Element?}
*/
getElementById(id) {

@@ -69,2 +78,5 @@ const {root} = this;

/**
* This throws on Document instances.
*/
prepend(...nodes) {

@@ -74,2 +86,5 @@ throw new Error('Cannot have more than one Element child of a Document');

/**
* This throws on Document instances.
*/
append(...nodes) {

@@ -79,2 +94,5 @@ throw new Error('Cannot have more than one Element child of a Document');

/**
* This throws on Document instances.
*/
replaceChildren(...nodes) {

@@ -103,2 +121,6 @@ throw new Error('Cannot have more than one Element child of a Document');

/**
* @param {string} name
* @returns {Attr}
*/
createAttribute(name) {

@@ -133,2 +155,25 @@ return new Attr(this, name, '');

/**
* @deprecated
* @param {"Event"|"CustomEvent"} name
* @returns {Event|CustomEvent}
*/
createEvent(name) {
const event = create(name === 'Event' ? new Event('') : new CustomEvent(''));
event.initEvent = event.initCustomEvent = (
type,
canBubble = false,
cancelable = false,
detail
) => {
defineProperties(event, {
type: {value: type},
canBubble: {value: canBubble},
cancelable: {value: cancelable},
detail: {value: detail}
});
};
return event;
}
/**
* @param {string} textContent

@@ -160,2 +205,10 @@ */

/**
* @param {Node} node
* @param {boolean?} deep
*/
importNode(node, deep = false) {
return node.cloneNode(deep);
}
/**
* @param {string} name

@@ -162,0 +215,0 @@ * @returns {NodeList}

@@ -0,1 +1,2 @@

import {getEnd} from './utils.js';
import {Document} from './document.js';

@@ -20,2 +21,53 @@

}
/**
* @type HTMLAllCollection
*/
get all() {
const all = [this.root];
let {_next, _end} = all[0];
while (_next !== _end) {
all.push(_next);
_next = getEnd(_next)._next;
}
return all;
}
/**
* @type HTMLHeadElement
*/
get head() {
let {firstElementChild} = this.root;
// whatever
if (!firstElementChild) {
firstElementChild = this.createElement('head');
this.root.prepend(firstElementChild);
}
return firstElementChild;
}
/**
* @type HTMLBodyElement
*/
get body() {
let {nextElementSibling} = this.head;
// whatever
if (!nextElementSibling) {
nextElementSibling = this.createElement('body');
this.head.after(nextElementSibling);
}
return nextElementSibling;
}
/**
* @type HTMLTitleElement
*/
get title() {
let title = this.head.getElementsByTagName('title').shift();
if (!title) {
title = this.createElement('title');
this.head.prepend(title);
}
return title;
}
}

2

package.json
{
"name": "linkedom",
"version": "0.1.17",
"version": "0.1.18",
"description": "A triple-linked lists based DOM",

@@ -5,0 +5,0 @@ "main": "./cjs/index.js",

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