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

@marcoms/make-element

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@marcoms/make-element - npm Package Compare versions

Comparing version 4.0.3 to 4.1.0

2

package.json
{
"name": "@marcoms/make-element",
"version": "4.0.3",
"version": "4.1.0",
"description": "Create custom elements without boilerplate",

@@ -5,0 +5,0 @@ "main": "build/make-element.js",

@@ -99,2 +99,8 @@ # make-element

##### `boolAttr`
Whether the attribute is a boolean attribute
Boolean attributes automatically have defined a `toAttr` function that returns `''` (making the attribute true) on a truthy value and `undefined` (removing the attribute) on a falsy value.
##### `get(val)`

@@ -141,2 +147,4 @@

Return values of `undefined` will remove the attribute
##### `fromAttr(val)`

@@ -143,0 +151,0 @@

@@ -17,2 +17,3 @@ export interface ElementDef {

attr?: string;
boolAttr?: boolean;
set?: SetFn;

@@ -52,2 +53,9 @@ get?: GetFn;

interface RegisteredProp extends PropDef {
boolAttr: boolean;
set: SetFn;
get: GetFn;
toAttr: ToAttrFn;
fromAttr: FromAttrFn;
coerce: CoerceFn;
val: any;

@@ -86,2 +94,10 @@ hasSet: boolean;

function convertToBoolAttr(val) {
if (Boolean(val)) {
return '';
} else {
return undefined;
}
}
function makeElement(def: ElementDef = {}): CustomElementClass {

@@ -136,5 +152,11 @@ const props: PropDefs = def.props || {};

let boolAttr = false;
if (typeof propDef.boolAttr === 'boolean') {
boolAttr = propDef.boolAttr;
}
let toAttr = identity;
if (typeof propDef.toAttr === 'function') {
// this === element instance
if (boolAttr) {
toAttr = convertToBoolAttr;
} else if (typeof propDef.toAttr === 'function') {
toAttr = propDef.toAttr;

@@ -170,2 +192,4 @@ }

boolAttr,
// function used to produce an attribute value from a

@@ -248,4 +272,8 @@ // property value

// invoke attributeChangedCallback
this.setAttribute(attrName, attrVal);
if (attrVal !== undefined) {
// invoke attributeChangedCallback
this.setAttribute(attrName, attrVal);
} else {
this.removeAttribute(attrName);
}
}

@@ -252,0 +280,0 @@

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