@morbidick/lit-element-notify
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -1,2 +0,2 @@ | ||
export const notify = (baseElement) => class extends baseElement { | ||
export const LitNotify = (baseElement) => class extends baseElement { | ||
/** | ||
@@ -20,4 +20,4 @@ * Extend the LitElement `createProperty` method to map properties to events | ||
*/ | ||
update(props) { | ||
super.update(props); | ||
update(changedProps) { | ||
super.update(changedProps); | ||
@@ -29,3 +29,3 @@ if (!this.constructor._propertyEventMap) { | ||
for (const [eventProp, eventName] of this.constructor._propertyEventMap.entries()) { | ||
if (props.has(eventProp)) { | ||
if (changedProps.has(eventProp)) { | ||
this.dispatchEvent(new CustomEvent(eventName, { | ||
@@ -46,7 +46,9 @@ detail: { | ||
static _eventNameForProperty(name, options) { | ||
if (options.notify && typeof options.notify === 'string') | ||
if (options.notify && typeof options.notify === 'string') { | ||
return options.notify; | ||
} | ||
if (options.attribute && typeof options.attribute === 'string') | ||
if (options.attribute && typeof options.attribute === 'string') { | ||
return `${options.attribute}-changed`; | ||
} | ||
@@ -57,2 +59,2 @@ return `${name.toLowerCase()}-changed`; | ||
export default notify; | ||
export default LitNotify; |
{ | ||
"name": "@morbidick/lit-element-notify", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Small mixin for LitElement to get easy change events via the properties getter", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -17,5 +17,5 @@ # Change notification mixin for LitElement | ||
import { LitElement, html } from '@polymer/lit-element/lit-element.js'; | ||
import notify from '@morbidick/lit-element-notify/lit-element-notify.js'; | ||
import LitNotify from '@morbidick/lit-element-notify/lit-element-notify.js'; | ||
class notifyingElement extends notify(LitElement) { | ||
class NotifyingElement extends LitNotify(LitElement) { | ||
static get properties() { | ||
@@ -40,3 +40,3 @@ return { | ||
// if an attribute value is set, -changed is appended | ||
// if an attribute value is set, -changed is appended | ||
anotherProperty: { | ||
@@ -47,5 +47,6 @@ type: String, | ||
}, | ||
}; | ||
} | ||
} | ||
``` | ||
``` |
3348
47
50