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.8 to 0.0.9

2

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

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

@@ -0,5 +1,6 @@

import { r } from './state.js';
import { argsToArray, isReactive, toString, kebab } from './common.js';
const symbol = Symbol();
const Builder = (effect, tasks=[], names=[]) => new Proxy(
export const Builder = (effect, tasks=[], names=[]) => new Proxy(
(...args) => args[0] === symbol

@@ -12,2 +13,3 @@ ? (args[0] = tasks, effect(...args))

});
Builder.launch = (f, ...a) => f(symbol, ...a);

@@ -23,7 +25,7 @@ const elementBuilder = func => {

}
export const Operator = (reactive, func) => {
export const Operator = (func) => {
const effect = (tasks, node, init) => {
for (const {names, args} of tasks) {
const r = typeof reactive == 'function' ? reactive(args) : reactive;
if (init && !r || r) func(node, names, args);
const reactive = isReactive(args);
if (init || reactive) r.effect(() => func(node, names, args));
}

@@ -35,3 +37,3 @@ }

const textContent = Operator(isReactive, (node, _, args) => {
const textContent = Operator((node, _, args) => {
node.textContent = toString(args);

@@ -41,3 +43,2 @@ });

export const Element = tag => elementBuilder((content, node, init) => {
const node_ = node;
if (!node && (init = true)) switch (tag) {

@@ -51,5 +52,8 @@ case '': node = document.createTextNode(''); break;

let child = init ? null : node.firstChild;
const append = item => node.appendChild(item(symbol, null, init));
const apply = item => item(symbol, node, init);
const hydrate = item => (item(symbol, child, init), child = child.nextSibling);
const append = item => node.appendChild(Builder.launch(item, null, init));
const apply = item => Builder.launch(item, node, init);
const hydrate = item => {
Builder.launch(item, child, init);
child = child.nextSibling;
}

@@ -71,6 +75,7 @@ for (const item of argsToArray(content)) switch (item[symbol]) {

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