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

@morbidick/lit-element-notify

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@morbidick/lit-element-notify - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

.editorconfig

47

lit-element-notify.js
export const notify = (baseElement) => class extends baseElement {
constructor() {
super();
/**
* Extend the LitElement `createProperty` method to map properties to events
*/
static createProperty(name, options) {
super.createProperty(name, options);
this._propertyEventMap = new Map();
const props = this.constructor.properties;
for (const prop of Object.getOwnPropertyNames(props)) {
const config = props[prop];
if (config.notify) {
this._propertyEventMap.set(prop, this.constructor._eventName(prop, config));
}
if (!this.hasOwnProperty('_propertyEventMap')) {
this._propertyEventMap = new Map();
}
if (options.notify) {
this._propertyEventMap.set(name, this._eventNameForProperty(name, options));
}
}
/**
* check for changed properties with notify option and fire the events
*/
update(props) {
super.update(props);
for (const [eventProp, eventName] of this._propertyEventMap.entries()) {
if (!this.constructor._propertyEventMap) {
return;
}
for (const [eventProp, eventName] of this.constructor._propertyEventMap.entries()) {
if (props.has(eventProp)) {

@@ -32,13 +40,16 @@ this.dispatchEvent(new CustomEvent(eventName, {

static _eventName(property, config) {
if (config.notify && typeof config.notify === 'string')
return config.notify;
/**
* Returns the event name for the given property.
*/
static _eventNameForProperty(name, options) {
if (options.notify && typeof options.notify === 'string')
return options.notify;
if (config.attribute && typeof config.attribute === 'string')
return `${config.attribute}-changed`;
if (options.attribute && typeof options.attribute === 'string')
return `${options.attribute}-changed`;
return `${property.toLowerCase()}-changed`;
return `${name.toLowerCase()}-changed`;
}
};
export default notify;
export default notify;
{
"name": "@morbidick/lit-element-notify",
"version": "0.1.0",
"version": "0.2.0",
"description": "Small mixin for LitElement to get easy change events via the properties getter",

@@ -5,0 +5,0 @@ "license": "MIT",

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