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

realdom

Package Overview
Dependencies
Maintainers
0
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

realdom - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

2

package.json
{
"name": "realdom",
"version": "0.0.5",
"version": "0.0.6",
"author": "Fedot Kriutchenko <fodyadev@gmail.com>",

@@ -5,0 +5,0 @@ "description": "",

import { runWithState, getCurrentHandler } from './state.js';
import { argsToArray, toString, kebab } from './common.js';
import { argsToArray, isReactive, toString, kebab } from './common.js';

@@ -32,3 +32,3 @@ const symbol = Symbol();

const r = typeof reactive == 'function' ? reactive(args) : reactive;
if (init || r) func(node, names, args);
if (init && !r || r) func(node, names, args);
}

@@ -42,2 +42,6 @@ effect[symbol] = 2;

const textContent = Operator(true, (node, _, args) => {
node.textContent = toString(args);
});
const elementBuilder = effect => {

@@ -48,22 +52,25 @@ effect[symbol] = 1;

export const Element = tag => elementBuilder((_, content, node, init) => {
init ??= !node;
node ??= (
tag === '' ? document.createTextNode('') :
document.createElement(tag)
);
const node_ = node;
if (!node && (init = true)) switch (tag) {
case '': node = document.createTextNode(''); break;
case '!': node = document.createComment(''); break;
case ':': node = document.createDocumentFragment(); break;
default: node = document.createElement(tag);
}
let childNode;
for (const item of argsToArray(content)) {
const type = typeof item == 'function' && item[symbol];
if (type === 1) {
if (init) {
node.appendChild(item(symbol, null, init));
} else {
item(symbol, childNode ??= node.firstChild, init);
childNode = childNode.nextSibling;
let child = init ? null : node.firstChild;
for (const item of argsToArray(content)) switch (item[symbol]) {
case 1:
if (init) node.appendChild(item(symbol, null, init));
else (item(symbol, child, init), child = child.nextSibling);
break;
case 2: item(symbol, node, init); break;
default:
if (tag === '' || tag === '!') textContent(item)(symbol, node, init);
else if (init)
node.appendChild(Element('')(textContent(item))(symbol, null, init));
else {
textContent(item)(symbol, child, init);
child = child.nextSibling;
}
}
else if (type === 2) item(symbol, node, init);
else if (tag === '') node.textContent = toString(item);
else Element('')(item)(symbol, node, init);
}

@@ -76,6 +83,6 @@ return node;

return (...args) => {
const clone = func(...args)(symbol, tmpl?.cloneNode?.(true));
tmpl ??= clone;
return clone;
const node = func(...args)(symbol, tmpl ? tmpl.cloneNode(true) : null);
tmpl ??= node;
return node;
}
}
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