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.1.7 to 4.1.8

26

build/make-element.js

@@ -113,6 +113,6 @@ (function webpackUniversalModuleDefinition(root, factory) {

const propDef = props[propName];
let val = null;
let init = null;
if (propDef.init !== undefined) {
// initial value for the property
val = propDef.init;
init = propDef.init;
}

@@ -162,4 +162,6 @@ let hasAttr = typeof propDef.attr === 'string';

registeredProps[propName] = {
// initial value
init,
// internal value
val,
val: null,
// linked attribute name

@@ -190,4 +192,10 @@ attr: attrName,

this._readyFn = readyFn;
this._props = registeredProps;
this._attrs = registeredAttrs;
this._props = {};
this._attrs = {};
Object.keys(registeredProps).map((prop) => {
this._props[prop] = Object.assign({}, registeredProps[prop]);
});
Object.keys(registeredAttrs).map((attr) => {
this._attrs[attr] = Object.assign({}, registeredAttrs[attr]);
});
for (const propName of Object.keys(this._props)) {

@@ -293,9 +301,9 @@ // convenience aliases

const internalProp = this._props[propName];
// if there is a value but the setter has not run
if (internalProp.val !== undefined
&& internalProp.val !== null
// if there is a defined initial value but the setter has not run
if (internalProp.init !== undefined
&& internalProp.init !== null
&& !internalProp.hasSet) {
internalProp.settingInitialValue = true;
// kick off property setter
this[propName] = internalProp.val;
this[propName] = internalProp.init;
}

@@ -302,0 +310,0 @@ }

{
"name": "@marcoms/make-element",
"version": "4.1.7",
"version": "4.1.8",
"description": "Create custom elements without boilerplate",

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

@@ -126,6 +126,6 @@ export interface ArbitraryFn { (this: CustomElement, ...args: any[]): any; }

let val = null;
let init = null;
if (propDef.init !== undefined) {
// initial value for the property
val = propDef.init;
init = propDef.init;
}

@@ -187,4 +187,7 @@

registeredProps[propName] = {
// initial value
init,
// internal value
val,
val: null,

@@ -227,4 +230,4 @@ // linked attribute name

private _readyFn: ReadyFn = readyFn;
private _props: RegisteredProps = registeredProps;
private _attrs: RegisteredAttrs = registeredAttrs;
private _props: RegisteredProps = {};
private _attrs: RegisteredAttrs = {};

@@ -234,2 +237,10 @@ constructor() {

Object.keys(registeredProps).map((prop) => {
this._props[prop] = Object.assign({}, registeredProps[prop]);
});
Object.keys(registeredAttrs).map((attr) => {
this._attrs[attr] = Object.assign({}, registeredAttrs[attr]);
});
for (const propName of Object.keys(this._props)) {

@@ -355,7 +366,7 @@ // convenience aliases

// if there is a value but the setter has not run
// if there is a defined initial value but the setter has not run
if (
internalProp.val !== undefined
&& internalProp.val !== null
internalProp.init !== undefined
&& internalProp.init !== null
&& !internalProp.hasSet

@@ -366,3 +377,3 @@ ) {

// kick off property setter
this[propName] = internalProp.val;
this[propName] = internalProp.init;
}

@@ -369,0 +380,0 @@ }

@@ -274,6 +274,33 @@ import { assert } from 'chai';

customElements.define(customElName(), El);
const el = new El();
assert.strictEqual(el.prop, 24);
const elA = new El();
document.body.appendChild(elA);
assert.strictEqual(elA.prop, 24);
const elB = new El();
document.body.appendChild(elB);
assert.strictEqual(elB.prop, 24);
});
it('should flow initialization value to attribute', () => {
const El = me({
props: {
prop: {
attr: 'prop',
init: 24,
},
},
});
customElements.define(customElName(), El);
const elA = new El();
document.body.appendChild(elA);
assert.strictEqual(elA.getAttribute('prop'), '24');
const elB = new El();
document.body.appendChild(elB);
assert.strictEqual(elB.getAttribute('prop'), '24');
});
it('should prefer initialization from linked attribute vs init', () => {

@@ -280,0 +307,0 @@ const El = me({

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