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

as-custom-element

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

as-custom-element - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

esm.js

65

index.js

@@ -5,4 +5,5 @@ self.asCustomElement = (function (exports) {

var TRUE = true,
FALSE = false;
FALSE = false;
var QSA = 'querySelectorAll';
/**

@@ -15,3 +16,2 @@ * Start observing a generic document or root element.

*/
var notify = function notify(callback, root, MO) {

@@ -21,3 +21,2 @@ var loop = function loop(nodes, added, removed, connected, pass) {

var node = nodes[i];
if (pass || QSA in node) {

@@ -35,3 +34,2 @@ if (connected) {

}
if (!pass) loop((node.shadowRoot || node)[QSA]('*'), added, removed, connected, TRUE);

@@ -41,8 +39,7 @@ }

};
var observer = new (MO || MutationObserver)(function (records) {
for (var added = new Set(), removed = new Set(), i = 0, length = records.length; i < length; i++) {
var _records$i = records[i],
addedNodes = _records$i.addedNodes,
removedNodes = _records$i.removedNodes;
addedNodes = _records$i.addedNodes,
removedNodes = _records$i.removedNodes;
loop(removedNodes, added, removed, FALSE, FALSE);

@@ -60,14 +57,11 @@ loop(addedNodes, added, removed, TRUE, FALSE);

var lifecycle = new WeakMap();
var attributeChanged = function attributeChanged(records, mo) {
var _loop = function _loop(i, length) {
var _loop = function _loop() {
var _records$i = records[i],
target = _records$i.target,
attributeName = _records$i.attributeName,
oldValue = _records$i.oldValue;
target = _records$i.target,
attributeName = _records$i.attributeName,
oldValue = _records$i.oldValue;
if (lifecycle.has(target)) {
var _lifecycle$get = lifecycle.get(target),
a = _lifecycle$get.a;
a = _lifecycle$get.a;
var newValue = target.getAttribute(attributeName);

@@ -79,8 +73,6 @@ a.forEach(function (observedAttributes, attributeChangedCallback) {

};
for (var i = 0, length = records.length; i < length; i++) {
_loop(i);
_loop();
}
};
notify(function (element, connected) {

@@ -91,6 +83,6 @@ if (lifecycle.has(element)) lifecycle.get(element)[connected ? 'c' : 'd'].forEach(call, element);

var upgradedCallback = _ref.upgradedCallback,
connectedCallback = _ref.connectedCallback,
disconnectedCallback = _ref.disconnectedCallback,
observedAttributes = _ref.observedAttributes,
attributeChangedCallback = _ref.attributeChangedCallback;
connectedCallback = _ref.connectedCallback,
disconnectedCallback = _ref.disconnectedCallback,
observedAttributes = _ref.observedAttributes,
attributeChangedCallback = _ref.attributeChangedCallback;
if (!lifecycle.has(element)) lifecycle.set(element, {

@@ -102,8 +94,6 @@ a: new Map(),

if (upgradedCallback) upgradedCallback.call(element);
var _lifecycle$get2 = lifecycle.get(element),
a = _lifecycle$get2.a,
c = _lifecycle$get2.c,
d = _lifecycle$get2.d;
a = _lifecycle$get2.a,
c = _lifecycle$get2.c,
d = _lifecycle$get2.d;
if (attributeChangedCallback) {

@@ -122,5 +112,3 @@ var mo = new MutationObserver(attributeChanged);

}
if (disconnectedCallback) d.add(disconnectedCallback);
if (connectedCallback) {

@@ -130,3 +118,2 @@ c.add(connectedCallback);

}
return element;

@@ -136,12 +123,10 @@ };

var downgradedCallback = _ref2.downgradedCallback,
connectedCallback = _ref2.connectedCallback,
disconnectedCallback = _ref2.disconnectedCallback,
attributeChangedCallback = _ref2.attributeChangedCallback;
connectedCallback = _ref2.connectedCallback,
disconnectedCallback = _ref2.disconnectedCallback,
attributeChangedCallback = _ref2.attributeChangedCallback;
if (lifecycle.has(element)) {
var _lifecycle$get3 = lifecycle.get(element),
a = _lifecycle$get3.a,
c = _lifecycle$get3.c,
d = _lifecycle$get3.d;
a = _lifecycle$get3.a,
c = _lifecycle$get3.c,
d = _lifecycle$get3.d;
if (attributeChangedCallback) a["delete"](attributeChangedCallback);

@@ -153,6 +138,4 @@ if (disconnectedCallback) d["delete"](disconnectedCallback);

}
return element;
};
function call(back) {

@@ -167,2 +150,2 @@ back.call(this);

}({}));
})({});

@@ -1,1 +0,1 @@

self.asCustomElement=function(e){"use strict";var t,a,n,r,l=!0,c=!1,d="querySelectorAll",o=new WeakMap,i=function(e,t){for(var a=function(a,n){var r=e[a],l=r.target,c=r.attributeName,d=r.oldValue;if(o.has(l)){var i=o.get(l).a,u=l.getAttribute(c);i.forEach((function(e,t){-1<e.indexOf(c)&&t.call(l,c,d,u)}))}else t.disconnect()},n=0,r=e.length;n<r;n++)a(n)};t=function(e,t){o.has(e)&&o.get(e)[t?"c":"d"].forEach(u,e)},r=function e(a,n,r,c,o){for(var i=0,u=a.length;i<u;i++){var s=a[i];(o||d in s)&&(c?n.has(s)||(n.add(s),r.delete(s),t(s,c)):r.has(s)||(r.add(s),n.delete(s),t(s,c)),o||e((s.shadowRoot||s)[d]("*"),n,r,c,l))}},new(n||MutationObserver)((function(e){for(var t=new Set,a=new Set,n=0,d=e.length;n<d;n++){var o=e[n],i=o.addedNodes,u=o.removedNodes;r(u,t,a,c,c),r(i,t,a,l,c)}})).observe(a||document,{subtree:l,childList:l});function u(e){e.call(this)}return e.downgrade=function(e,t){var a=t.downgradedCallback,n=t.connectedCallback,r=t.disconnectedCallback,l=t.attributeChangedCallback;if(o.has(e)){var c=o.get(e),d=c.a,i=c.c,u=c.d;l&&d.delete(l),r&&u.delete(r),n&&i.delete(n),d.size+u.size+i.size<1&&o.delete(e),a&&a.call(e)}return e},e.upgrade=function(e,t){var a=t.upgradedCallback,n=t.connectedCallback,r=t.disconnectedCallback,l=t.observedAttributes,c=t.attributeChangedCallback;o.has(e)||o.set(e,{a:new Map,c:new Set,d:new Set}),a&&a.call(e);var d=o.get(e),u=d.a,s=d.c,b=d.d;c&&(new MutationObserver(i).observe(e,{attributes:!0,attributeOldValue:!0,attributeFilter:l.map((function(t){var a=e.getAttribute(t);return null!=a&&c.call(e,t,null,a),t}))}),u.set(c,l));return r&&b.add(r),n&&(s.add(n),e.ownerDocument.compareDocumentPosition(e)&e.DOCUMENT_POSITION_DISCONNECTED||n.call(e)),e},e}({});
self.asCustomElement=function(e){"use strict";var t,a,n,r,l=!0,c=!1,d="querySelectorAll",o=new WeakMap,i=function(e,t){for(var a=function(){var a=e[n],r=a.target,l=a.attributeName,c=a.oldValue;if(o.has(r)){var d=o.get(r).a,i=r.getAttribute(l);d.forEach((function(e,t){-1<e.indexOf(l)&&t.call(r,l,c,i)}))}else t.disconnect()},n=0,r=e.length;n<r;n++)a()};t=function(e,t){o.has(e)&&o.get(e)[t?"c":"d"].forEach(u,e)},r=function e(a,n,r,c,o){for(var i=0,u=a.length;i<u;i++){var s=a[i];(o||d in s)&&(c?n.has(s)||(n.add(s),r.delete(s),t(s,c)):r.has(s)||(r.add(s),n.delete(s),t(s,c)),o||e((s.shadowRoot||s)[d]("*"),n,r,c,l))}},new(n||MutationObserver)((function(e){for(var t=new Set,a=new Set,n=0,d=e.length;n<d;n++){var o=e[n],i=o.addedNodes,u=o.removedNodes;r(u,t,a,c,c),r(i,t,a,l,c)}})).observe(a||document,{subtree:l,childList:l});function u(e){e.call(this)}return e.downgrade=function(e,t){var a=t.downgradedCallback,n=t.connectedCallback,r=t.disconnectedCallback,l=t.attributeChangedCallback;if(o.has(e)){var c=o.get(e),d=c.a,i=c.c,u=c.d;l&&d.delete(l),r&&u.delete(r),n&&i.delete(n),d.size+u.size+i.size<1&&o.delete(e),a&&a.call(e)}return e},e.upgrade=function(e,t){var a=t.upgradedCallback,n=t.connectedCallback,r=t.disconnectedCallback,l=t.observedAttributes,c=t.attributeChangedCallback;o.has(e)||o.set(e,{a:new Map,c:new Set,d:new Set}),a&&a.call(e);var d=o.get(e),u=d.a,s=d.c,b=d.d;c&&(new MutationObserver(i).observe(e,{attributes:!0,attributeOldValue:!0,attributeFilter:l.map((function(t){var a=e.getAttribute(t);return null!=a&&c.call(e,t,null,a),t}))}),u.set(c,l));return r&&b.add(r),n&&(s.add(n),e.ownerDocument.compareDocumentPosition(e)&e.DOCUMENT_POSITION_DISCONNECTED||n.call(e)),e},e}({});
{
"name": "as-custom-element",
"version": "1.0.0",
"version": "2.0.0",
"description": "Setup any element as if it was a Custom Element",
"main": "./cjs/index.js",
"scripts": {
"build": "npm run cjs && npm run rollup:es && npm run rollup:babel && npm run min && npm run size",
"build": "npm run cjs && npm run rollup:es && npm run rollup:esm && npm run rollup:babel && npm run min && npm run size",
"cjs": "ascjs --no-default esm cjs",
"rollup:es": "rollup --config rollup/es.config.js && sed -i.bck 's/^var /self./' es.js && rm -rf es.js.bck",
"rollup:esm": "rollup --config rollup/esm.config.js",
"rollup:babel": "rollup --config rollup/babel.config.js && sed -i.bck 's/^var /self./' index.js && rm -rf index.js.bck",
"min": "terser index.js --comments='/^!/' -c -m -o min.js",
"size": "cat min.js | gzip -9 | wc -c && cat min.js | brotli | wc -c && cat es.js | gzip -9 | wc -c && cat es.js | brotli | wc -c"
"size": "cat min.js | gzip -9 | wc -c && cat min.js | brotli | wc -c && cat es.js | gzip -9 | wc -c && cat es.js | brotli | wc -c && cat esm.js | brotli | wc -c"
},

@@ -40,3 +41,3 @@ "keywords": [

},
"unpkg": "min.js",
"unpkg": "esm.js",
"repository": {

@@ -43,0 +44,0 @@ "type": "git",

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