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

haunted

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

haunted - npm Package Compare versions

Comparing version 4.1.3 to 4.1.4

46

haunted.js

@@ -34,2 +34,4 @@ import { render, directive } from 'https://unpkg.com/lit-html@^1.0.0/lit-html.js';

const defer = Promise.resolve().then.bind(Promise.resolve());
function scheduler() {

@@ -51,3 +53,3 @@ let tasks = [];

if(id == null) {
id = requestAnimationFrame(runTasks);
id = defer(runTasks);
}

@@ -352,2 +354,5 @@ };

const partToContainer = new WeakMap();
const containerToPart = new WeakMap();
class DirectiveContainer extends Container {

@@ -363,13 +368,21 @@ constructor(renderer, part) {

}
teardown() {
super.teardown();
let part = containerToPart.get(this);
partToContainer.delete(part);
}
}
const map = new WeakMap();
function withHooks(renderer) {
function factory(...args) {
return part => {
let cont = map.get(part);
let cont = partToContainer.get(part);
if(!cont) {
cont = new DirectiveContainer(renderer, part);
map.set(part, cont);
partToContainer.set(part, cont);
containerToPart.set(cont, part);
teardownOnRemove(cont, part);
}

@@ -384,2 +397,27 @@ cont.args = args;

const includes = Array.prototype.includes;
function teardownOnRemove(cont, part, node = part.startNode) {
let frag = node.parentNode;
let mo = new MutationObserver(mutations => {
for(let mutation of mutations) {
if(includes.call(mutation.removedNodes, node)) {
mo.disconnect();
if(node.parentNode instanceof ShadowRoot) {
teardownOnRemove(cont, part);
} else {
cont.teardown();
}
break;
} else if(includes.call(mutation.addedNodes, node.nextSibling)) {
mo.disconnect();
teardownOnRemove(cont, part, node.nextSibling);
break;
}
}
});
mo.observe(frag, { childList: true });
}
function setContexts(el, consumer) {

@@ -386,0 +424,0 @@ if(!(contextSymbol in el)) {

@@ -34,2 +34,4 @@ import { render, directive } from 'lit-html';

const defer = Promise.resolve().then.bind(Promise.resolve());
function scheduler() {

@@ -51,3 +53,3 @@ let tasks = [];

if(id == null) {
id = requestAnimationFrame(runTasks);
id = defer(runTasks);
}

@@ -352,2 +354,5 @@ };

const partToContainer = new WeakMap();
const containerToPart = new WeakMap();
class DirectiveContainer extends Container {

@@ -363,13 +368,21 @@ constructor(renderer, part) {

}
teardown() {
super.teardown();
let part = containerToPart.get(this);
partToContainer.delete(part);
}
}
const map = new WeakMap();
function withHooks(renderer) {
function factory(...args) {
return part => {
let cont = map.get(part);
let cont = partToContainer.get(part);
if(!cont) {
cont = new DirectiveContainer(renderer, part);
map.set(part, cont);
partToContainer.set(part, cont);
containerToPart.set(cont, part);
teardownOnRemove(cont, part);
}

@@ -384,2 +397,27 @@ cont.args = args;

const includes = Array.prototype.includes;
function teardownOnRemove(cont, part, node = part.startNode) {
let frag = node.parentNode;
let mo = new MutationObserver(mutations => {
for(let mutation of mutations) {
if(includes.call(mutation.removedNodes, node)) {
mo.disconnect();
if(node.parentNode instanceof ShadowRoot) {
teardownOnRemove(cont, part);
} else {
cont.teardown();
}
break;
} else if(includes.call(mutation.addedNodes, node.nextSibling)) {
mo.disconnect();
teardownOnRemove(cont, part, node.nextSibling);
break;
}
}
});
mo.observe(frag, { childList: true });
}
function setContexts(el, consumer) {

@@ -386,0 +424,0 @@ if(!(contextSymbol in el)) {

4

package.json
{
"name": "haunted",
"version": "4.1.3",
"version": "4.1.4",
"description": "",

@@ -9,3 +9,3 @@ "main": "index.js",

"preversion": "make",
"testee": "testee --browsers firefox test/test.html",
"testee": "testee --browsers chrome test/test.html --config=testee.json",
"test": "npm run build && npm run testee"

@@ -12,0 +12,0 @@ },

# Haunted 🦇 🎃
React's Hooks API but for standard web components and [hyperHTML](https://codepen.io/WebReflection/pen/pxXrdy?editors=0010) or [lit-html](https://polymer.github.io/lit-html/).
React's Hooks API but for standard web components and [hyperHTML](https://codepen.io/WebReflection/pen/pxXrdy?editors=0010) or [lit-html](https://lit-html.polymer-project.org/).

@@ -97,3 +97,3 @@ ```html

In custom elements, attributes must be pre-defined. Properties, on the other hand, do not. Do define what attributes your component supports, set the `observedAttributes` property on the functional component. For example:
In custom elements, attributes must be pre-defined. Properties, on the other hand, do not. To define what attributes your component supports, set the `observedAttributes` property on the functional component. For example:

@@ -319,3 +319,3 @@ ```js

Grabs context value from the closest provider up in the tree and updates component when value of a provider changes.
Limited only to "real" components for now
Limited only to "real" components for now.

@@ -322,0 +322,0 @@ ```html

@@ -34,2 +34,4 @@ import { render, directive } from '../lit-html/lit-html.js';

const defer = Promise.resolve().then.bind(Promise.resolve());
function scheduler() {

@@ -51,3 +53,3 @@ let tasks = [];

if(id == null) {
id = requestAnimationFrame(runTasks);
id = defer(runTasks);
}

@@ -352,2 +354,5 @@ };

const partToContainer = new WeakMap();
const containerToPart = new WeakMap();
class DirectiveContainer extends Container {

@@ -363,13 +368,21 @@ constructor(renderer, part) {

}
teardown() {
super.teardown();
let part = containerToPart.get(this);
partToContainer.delete(part);
}
}
const map = new WeakMap();
function withHooks(renderer) {
function factory(...args) {
return part => {
let cont = map.get(part);
let cont = partToContainer.get(part);
if(!cont) {
cont = new DirectiveContainer(renderer, part);
map.set(part, cont);
partToContainer.set(part, cont);
containerToPart.set(cont, part);
teardownOnRemove(cont, part);
}

@@ -384,2 +397,27 @@ cont.args = args;

const includes = Array.prototype.includes;
function teardownOnRemove(cont, part, node = part.startNode) {
let frag = node.parentNode;
let mo = new MutationObserver(mutations => {
for(let mutation of mutations) {
if(includes.call(mutation.removedNodes, node)) {
mo.disconnect();
if(node.parentNode instanceof ShadowRoot) {
teardownOnRemove(cont, part);
} else {
cont.teardown();
}
break;
} else if(includes.call(mutation.addedNodes, node.nextSibling)) {
mo.disconnect();
teardownOnRemove(cont, part, node.nextSibling);
break;
}
}
});
mo.observe(frag, { childList: true });
}
function setContexts(el, consumer) {

@@ -386,0 +424,0 @@ if(!(contextSymbol in el)) {

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