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

bobril

Package Overview
Dependencies
Maintainers
1
Versions
315
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bobril - npm Package Compare versions

Comparing version 18.1.0 to 18.2.0

6

CHANGELOG.md
# CHANGELOG
## 18.2.0
Fixed refs when switched instances during one render.
Custom events in WebComponent wrapper making it complete.
## 18.1.0

@@ -4,0 +10,0 @@

2

package.json
{
"name": "bobril",
"version": "18.1.0",
"version": "18.2.0",
"description": "Component Oriented MVC Framework with virtual DOM and CSS",

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

@@ -19,6 +19,10 @@ import {

interface WebComponentCtx<TData extends IWebComponentData> extends IBobrilCtx<TData> {
evMap?: Map<string, EventListenerObject>;
}
export function wrapWebComponent<TData extends IWebComponentData>(
name: string,
props: string[] = [],
_events?: { [name: string]: string }
events?: { [name: string]: string }
): (data?: TData) => IBobrilNode {

@@ -46,2 +50,38 @@ props = ["id", ...props];

} as IBobrilComponent<TData, IBobrilCtx<TData>>;
if (events != undefined) {
const eventProps = Object.keys(events);
component.init = (ctx: WebComponentCtx<TData>) => {
ctx.evMap = undefined;
};
component.postInitDom = component.postUpdateDom = (ctx: WebComponentCtx<TData>) => {
let d = ctx.data;
for (const n of eventProps) {
let e = (d as any)[n];
if (e == undefined) continue;
let es = ctx.evMap;
if (es == undefined) {
es = new Map();
ctx.evMap = es;
}
let en = events[n] as string;
if (!es.has(en)) {
let el = {
handleEvent(event: Event) {
e(event);
},
};
(ctx.me.element as HTMLElement).addEventListener(en, el);
es.set(en, el);
}
}
};
component.destroy = (ctx: WebComponentCtx<TData>) => {
let es = ctx.evMap;
if (es != undefined) {
es.forEach(function (this: HTMLElement, value: EventListenerObject, key: string) {
this.removeEventListener(key, value);
}, ctx.me.element as HTMLElement);
}
};
}

@@ -48,0 +88,0 @@ return (data?: TData): IBobrilNode => ({

Sorry, the diff of this file is too big to display

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