carbonium 1.2.1 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
- ![test](https://github.com/edwinm/carbonium/workflows/Test/badge.svg) [![Coverage Status](https://coveralls.io/repos/github/edwinm/carbonium/badge.svg?branch=master)](https://coveralls.io/github/edwinm/carbonium?branch=master) [![CodeFactor](https://www.codefactor.io/repository/github/edwinm/carbonium/badge)](https://www.codefactor.io/repository/github/edwinm/carbonium) [![Size](https://badgen.net/badgesize/gzip/edwinm/carbonium/master/dist/bundle.min.js)](https://bundlephobia.com/result?p=carbonium) [![npm version](https://badge.fury.io/js/carbonium.svg)](https://www.npmjs.com/package/carbonium) [![GitHub](https://img.shields.io/github/license/edwinm/carbonium.svg)](https://github.com/edwinm/carbonium/blob/master/LICENSE)
1
+ [![CodeQL](https://github.com/edwinm/carbonium/actions/workflows/codeql.yml/badge.svg)](https://github.com/edwinm/carbonium/actions/workflows/codeql.yml) [![Coverage Status](https://coveralls.io/repos/github/edwinm/carbonium/badge.svg?branch=master)](https://coveralls.io/github/edwinm/carbonium?branch=master) [![Socket Badge](https://socket.dev/api/badge/npm/package/carbonium)](https://socket.dev/npm/package/carbonium) [![CodeFactor](https://www.codefactor.io/repository/github/edwinm/carbonium/badge)](https://www.codefactor.io/repository/github/edwinm/carbonium) [![Size](https://badgen.net/badgesize/gzip/edwinm/carbonium/master/dist/bundle.min.js)](https://bundlephobia.com/result?p=carbonium) [![npm version](https://badge.fury.io/js/carbonium.svg)](https://www.npmjs.com/package/carbonium) [![GitHub](https://img.shields.io/github/license/edwinm/carbonium.svg)](https://github.com/edwinm/carbonium/blob/master/LICENSE)
2
2
 
3
3
  [![Carbonium](https://raw.githubusercontent.com/edwinm/carbonium/master/assets/carbonium.svg)](#readme)
4
4
 
5
- > One kilobyte library for easy manipulation of the DOM
5
+ > One kilobyte library for easy DOM manipulation
6
6
 
7
7
  With carbonium, you can call `$(selector)` and the result can be accessed as both an DOM element and an array of matched elements.
8
8
  DOM element operations are applied to all matched elements.
@@ -125,4 +125,4 @@ Just like this library, in which the result presents itself both as one element
125
125
 
126
126
  ## License
127
127
 
128
- Copyright 2020 [Edwin Martin](https://bitstorm.org/) and released under the MIT license.
128
+ Copyright 2023 [Edwin Martin](https://bitstorm.org/) and released under the MIT license.
@@ -1,7 +1,7 @@
1
1
  var carbonium=function(e){"use strict";
2
2
  /**
3
- Carbonium 1.2.0
3
+ Carbonium 1.2.3
4
4
  @copyright 2020 Edwin Martin
5
5
  @license MIT
6
- */let t,n;const o={get(e,r){let l=null;if(r==Symbol.iterator)return function*(){for(let t=0;t<e.length;t++)yield e[t]};if("style"==r||"classList"==r||"relList"==r){t=e,n=r;const l=Reflect.get(document.body,r);return new Proxy(l,o)}if(e instanceof CSSStyleDeclaration||e instanceof DOMTokenList)return l=Reflect.get(document.body[n],r),"function"==typeof l?new Proxy(l,{apply:function(e,r,l){return t.forEach((t=>{Reflect.apply(e,t[n],l)})),new Proxy(t,o)}}):l;if(Array.prototype.hasOwnProperty(r)){const e=Reflect.get(Array.prototype,r);if("function"==typeof e)return new Proxy(e,{apply:function(e,t,n){const r=Reflect.apply(e,t,n);return new Proxy(void 0!==r?r:t,o)}})}return e.length>0?r in e[0]&&(l=Reflect.get(e[0],r)):r in document.body&&(l=Reflect.get(document.body,r)),l?"function"==typeof l?new Proxy(l,{apply:function(e,t,n){let o=null,r=!0;for(const l of t){const t=Reflect.apply(e,l,n);r&&(o=t,r=!1)}return null!=o&&null!=o?o:t}}):l:Reflect.get(e,r)},set:(e,t,n)=>(!("forEach"in e)||e instanceof CSSStyleDeclaration?Reflect.set(e,t,n):e.forEach((e=>{Reflect.set(e,t,n)})),!0),deleteProperty:(e,t)=>t in e&&delete e[t]};return e.$=function(e,t){let n;return n="<"==e[0]?[(new DOMParser).parseFromString(e,"text/html").body.firstChild]:(t||document).querySelectorAll(e),new Proxy(n,o)},Object.defineProperty(e,"__esModule",{value:!0}),e}({});
6
+ */let t,n;const o={get(e,r){let l=null;if(r==Symbol.iterator)return function*(){for(let t=0;t<e.length;t++)yield e[t]};if("style"==r||"classList"==r||"relList"==r){t=e,n=r;const l=Reflect.get(document.body,r);return new Proxy(l,o)}if(e instanceof CSSStyleDeclaration||e instanceof DOMTokenList)return l=Reflect.get(document.body[n],r),"function"==typeof l?new Proxy(l,{apply:function(e,r,l){return t.forEach((t=>{Reflect.apply(e,t[n],l)})),new Proxy(t,o)}}):l;if(Array.prototype.hasOwnProperty(r)){const e=Reflect.get(Array.prototype,r);if("function"==typeof e)return new Proxy(e,{apply:function(e,t,n){const r=Reflect.apply(e,t,n);return new Proxy(void 0!==r?r:t,o)}})}return e.length>0?r in e[0]&&(l=Reflect.get(e[0],r)):r in document.body&&(l=Reflect.get(document.body,r)),l?"function"==typeof l?new Proxy(l,{apply:function(e,t,n){let o=null,r=!0;for(const l of t){const t=Reflect.apply(e,l,n);r&&(o=t,r=!1)}return null!=o&&null!=o?o:t}}):l:Reflect.get(e,r)},set:(e,t,n)=>(!("forEach"in e)||e instanceof CSSStyleDeclaration?Reflect.set(e,t,n):e.forEach((e=>{Reflect.set(e,t,n)})),!0),deleteProperty:(e,t)=>t in e&&delete e[t]};return e.$=function(e,t){let n;return n="<"==e[0]?[(new DOMParser).parseFromString(e,"text/html").body.firstChild]:(t||document).querySelectorAll(e),new Proxy(n,o)},e}({});
7
7
  //# sourceMappingURL=bundle.iife.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"bundle.iife.min.js","sources":["../src/carbonium.ts"],"sourcesContent":["/**\n Carbonium __buildVersion__\n @copyright 2020 Edwin Martin\n @license MIT\n */\n\nexport function $<T extends HTMLElement = HTMLElement>(\n selectors: string,\n parentNode?: Document | ShadowRoot | HTMLElement\n): CarboniumType<T> {\n let nodelist: NodeListOf<T>;\n\n // If the first parameter starts with \"<\", create a DOM node\n if (selectors[0] == \"<\") {\n nodelist = <NodeListOf<T>>(\n (<unknown>[\n new DOMParser().parseFromString(selectors, \"text/html\").body.firstChild,\n ])\n );\n } else {\n // Else, do querySelectorAll\n nodelist = (parentNode || document).querySelectorAll(selectors);\n }\n\n // Wrap it in a Proxy\n return <CarboniumType<T>>(\n (<unknown>new Proxy<NodeListOf<T>>(nodelist, proxyHandler))\n );\n}\n\n// Used by style, classList and relList\n// When setting one of these, remember the elements to apply to\nlet currentListNodelist: NodeListOf<HTMLElement>;\nlet propList: \"style\" | \"classList\" | \"relList\";\n\nconst proxyHandler: ProxyHandler<NodeListOf<HTMLElement>> = {\n get(target, prop) {\n let propValue = null;\n\n // Return iterator when asked for iterator, only used in ES2015+\n if (prop == Symbol.iterator) {\n return function* () {\n for (let i = 0; i < target.length; i++) {\n yield target[i];\n }\n };\n }\n\n // Special case for style, classList and relList\n if (prop == \"style\" || prop == \"classList\" || prop == \"relList\") {\n currentListNodelist = target;\n propList = prop;\n // Matched elements can be a list of any element or an empty list\n // Use getter of, for example, document.body.style\n const propValue = Reflect.get(document.body, prop);\n return new Proxy(propValue, proxyHandler);\n }\n\n // style.setProperty, getPropertyValue…, classList.add, contains, remove…, relList…\n if (\n target instanceof CSSStyleDeclaration ||\n target instanceof DOMTokenList\n ) {\n // Matched elements can be a list of any element or an empty list\n // Use getter of, for example, document.body.style.color\n propValue = Reflect.get(document.body[propList], prop);\n\n // When getter is a function, apply it to all matched elements\n if (typeof propValue == \"function\") {\n return new Proxy<Function>(propValue, {\n apply: function (target, thisArg, argumentsList) {\n currentListNodelist.forEach((el) => {\n Reflect.apply(target, el[propList], argumentsList);\n });\n return new Proxy(currentListNodelist, proxyHandler);\n },\n });\n } else {\n return propValue;\n }\n }\n\n // Are we dealing with an Array function like forEach, map and filter?\n if (Array.prototype.hasOwnProperty(prop)) {\n const propValue = Reflect.get(Array.prototype, prop);\n if (typeof propValue == \"function\") {\n return new Proxy<Function>(propValue, {\n apply: function (target, thisArg, argumentsList) {\n const ret = Reflect.apply(target, thisArg, argumentsList);\n // When function returns undefined (like forEach),\n // return all matched elements, so calls can be chained\n // For example forEach(…).setAttribute(…)\n const newTarget = typeof ret != \"undefined\" ? ret : thisArg;\n return new Proxy(newTarget, proxyHandler);\n },\n });\n }\n }\n\n // Get property or call function on DOM elements\n if (target.length > 0) {\n // Might be DOM element specific, like input.select(),\n // so use first array element to get reference\n if (prop in target[0]) {\n propValue = Reflect.get(target[0], prop);\n }\n } else {\n // Empty list, targeted DOM element unknown,\n // use getter of document.body\n if (prop in document.body) {\n propValue = Reflect.get(document.body, prop);\n }\n }\n\n // Propagate DOM prop value\n if (propValue) {\n if (typeof propValue == \"function\") {\n return new Proxy<Function>(propValue, {\n apply: function (target, thisArg, argumentsList) {\n let retFirst = null;\n let first = true;\n // Apply on individual elements\n for (const el of thisArg) {\n const ret = Reflect.apply(target, el, argumentsList);\n if (first) {\n retFirst = ret;\n first = false;\n }\n }\n return retFirst != null && retFirst != undefined\n ? retFirst\n : thisArg;\n },\n });\n } else {\n return propValue;\n }\n }\n\n // Default\n return Reflect.get(target, prop);\n },\n\n // DOM property is set\n set(target, prop, value) {\n if (\"forEach\" in target && !(target instanceof CSSStyleDeclaration)) {\n target.forEach((el) => {\n Reflect.set(el, prop, value);\n });\n } else {\n Reflect.set(target, prop, value);\n }\n return true;\n },\n\n deleteProperty(target, prop) {\n if (prop in target) {\n return delete target[prop];\n }\n return false;\n },\n};\n\nexport type CarboniumType<T extends HTMLElement = HTMLElement> =\n CarboniumList<T> & T;\n\n// Interface definitions\n\ninterface CarboniumList<T extends HTMLElement> extends Array<T> {\n concat(...items: ConcatArray<T>[]): CarboniumType<T>;\n\n concat(...items: (T | ConcatArray<T>)[]): CarboniumType<T>;\n\n reverse(): CarboniumType<T>;\n\n slice(start?: number, end?: number): CarboniumType<T>;\n\n splice(start: number, deleteCount?: number): CarboniumType<T>;\n\n /* tslint:disable:unified-signatures */\n splice(start: number, deleteCount: number, ...items: T[]): CarboniumType<T>;\n\n forEach(\n callbackfn: (value: T, index: number, array: T[]) => void,\n thisArg?: any\n ): CarboniumType<T>;\n\n filter(\n callbackfn: (value: T, index: number, array: T[]) => boolean,\n thisArg?: any\n ): CarboniumType<T>;\n\n setAttribute(qualifiedName: string, value: string): CarboniumType<T>;\n\n classList: CarboniumClassList<T>;\n style: CarboniumStyleList<T>;\n}\n\ninterface CarboniumClassList<T extends HTMLElement> extends DOMTokenList {\n add(...tokens: string[]): CarboniumType<T>;\n\n remove(...tokens: string[]): CarboniumType<T>;\n\n replace(oldToken: string, newToken: string): boolean;\n\n forEach(\n callbackfn: (value: string, key: number, parent: DOMTokenList) => void,\n thisArg?: any\n ): CarboniumType<T>;\n}\n\ninterface CarboniumStyleList<T extends HTMLElement>\n extends CSSStyleDeclaration {\n removeProperty(property: string): CarboniumList<T> & string;\n\n setProperty(\n property: string,\n value: string | null,\n priority?: string\n ): CarboniumType<T>;\n}\n"],"names":["currentListNodelist","propList","proxyHandler","get","target","prop","propValue","Symbol","iterator","i","length","Reflect","document","body","Proxy","CSSStyleDeclaration","DOMTokenList","apply","thisArg","argumentsList","forEach","el","Array","prototype","hasOwnProperty","ret","retFirst","first","undefined","set","value","deleteProperty","selectors","parentNode","nodelist","DOMParser","parseFromString","firstChild","querySelectorAll"],"mappings":";;;;;KAgCA,IAAIA,EACAC,EAEJ,MAAMC,EAAsD,CAC1DC,IAAIC,EAAQC,GACV,IAAIC,EAAY,KAGhB,GAAID,GAAQE,OAAOC,SACjB,OAAO,YACL,IAAK,IAAIC,EAAI,EAAGA,EAAIL,EAAOM,OAAQD,UAC3BL,EAAOK,IAMnB,GAAY,SAARJ,GAA2B,aAARA,GAA+B,WAARA,EAAmB,CAC/DL,EAAsBI,EACtBH,EAAWI,EAGX,MAAMC,EAAYK,QAAQR,IAAIS,SAASC,KAAMR,GAC7C,OAAO,IAAIS,MAAMR,EAAWJ,GAI9B,GACEE,aAAkBW,qBAClBX,aAAkBY,aAOlB,OAHAV,EAAYK,QAAQR,IAAIS,SAASC,KAAKZ,GAAWI,G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AeJ,OAXEA,EADkB,KAAhBF,EAAU,GAEA,EACR,IAAIG,WAAYC,gBAAgBJ,EAAW,aAAanB,KAAKwB,aAKrDJ,GAAcrB,UAAU0B,iBAAiBN,GAK3C,IAAIlB,MAAqBoB,EAAUhC"}
1
+ {"version":3,"file":"bundle.iife.min.js","sources":["../src/carbonium.ts"],"sourcesContent":["/**\n Carbonium __buildVersion__\n @copyright 2020 Edwin Martin\n @license MIT\n */\n\nexport function $<T extends HTMLElement = HTMLElement>(\n selectors: string,\n parentNode?: Document | ShadowRoot | HTMLElement\n): CarboniumType<T> {\n let nodelist: NodeListOf<T>;\n\n // If the first parameter starts with \"<\", create a DOM node\n if (selectors[0] == \"<\") {\n nodelist = <NodeListOf<T>>(\n (<unknown>[\n new DOMParser().parseFromString(selectors, \"text/html\").body.firstChild,\n ])\n );\n } else {\n // Else, do querySelectorAll\n nodelist = (parentNode || document).querySelectorAll(selectors);\n }\n\n // Wrap it in a Proxy\n return <CarboniumType<T>>(\n (<unknown>new Proxy<NodeListOf<T>>(nodelist, proxyHandler))\n );\n}\n\n// Used by style, classList and relList\n// When setting one of these, remember the elements to apply to\nlet currentListNodelist: NodeListOf<HTMLElement>;\nlet propList: \"style\" | \"classList\" | \"relList\";\n\nconst proxyHandler: ProxyHandler<NodeListOf<HTMLElement>> = {\n get(target, prop) {\n let propValue = null;\n\n // Return iterator when asked for iterator, only used in ES2015+\n if (prop == Symbol.iterator) {\n return function* () {\n for (let i = 0; i < target.length; i++) {\n yield target[i];\n }\n };\n }\n\n // Special case for style, classList and relList\n if (prop == \"style\" || prop == \"classList\" || prop == \"relList\") {\n currentListNodelist = target;\n propList = prop;\n // Matched elements can be a list of any element or an empty list\n // Use getter of, for example, document.body.style\n const propValue = Reflect.get(document.body, prop);\n return new Proxy(propValue, proxyHandler);\n }\n\n // style.setProperty, getPropertyValue…, classList.add, contains, remove…, relList…\n if (\n target instanceof CSSStyleDeclaration ||\n target instanceof DOMTokenList\n ) {\n // Matched elements can be a list of any element or an empty list\n // Use getter of, for example, document.body.style.color\n propValue = Reflect.get(document.body[propList], prop);\n\n // When getter is a function, apply it to all matched elements\n if (typeof propValue == \"function\") {\n return new Proxy<Function>(propValue, {\n apply: function (target, thisArg, argumentsList) {\n currentListNodelist.forEach((el) => {\n Reflect.apply(target, el[propList], argumentsList);\n });\n return new Proxy(currentListNodelist, proxyHandler);\n },\n });\n } else {\n return propValue;\n }\n }\n\n // Are we dealing with an Array function like forEach, map and filter?\n if (Array.prototype.hasOwnProperty(prop)) {\n const propValue = Reflect.get(Array.prototype, prop);\n if (typeof propValue == \"function\") {\n return new Proxy<Function>(propValue, {\n apply: function (target, thisArg, argumentsList) {\n const ret = Reflect.apply(target, thisArg, argumentsList);\n // When function returns undefined (like forEach),\n // return all matched elements, so calls can be chained\n // For example forEach(…).setAttribute(…)\n const newTarget = typeof ret != \"undefined\" ? ret : thisArg;\n return new Proxy(newTarget, proxyHandler);\n },\n });\n }\n }\n\n // Get property or call function on DOM elements\n if (target.length > 0) {\n // Might be DOM element specific, like input.select(),\n // so use first array element to get reference\n if (prop in target[0]) {\n propValue = Reflect.get(target[0], prop);\n }\n } else {\n // Empty list, targeted DOM element unknown,\n // use getter of document.body\n if (prop in document.body) {\n propValue = Reflect.get(document.body, prop);\n }\n }\n\n // Propagate DOM prop value\n if (propValue) {\n if (typeof propValue == \"function\") {\n return new Proxy<Function>(propValue, {\n apply: function (target, thisArg, argumentsList) {\n let retFirst = null;\n let first = true;\n // Apply on individual elements\n for (const el of thisArg) {\n const ret = Reflect.apply(target, el, argumentsList);\n if (first) {\n retFirst = ret;\n first = false;\n }\n }\n return retFirst != null && retFirst != undefined\n ? retFirst\n : thisArg;\n },\n });\n } else {\n return propValue;\n }\n }\n\n // Default\n return Reflect.get(target, prop);\n },\n\n // DOM property is set\n set(target, prop, value) {\n if (\"forEach\" in target && !(target instanceof CSSStyleDeclaration)) {\n target.forEach((el) => {\n Reflect.set(el, prop, value);\n });\n } else {\n Reflect.set(target, prop, value);\n }\n return true;\n },\n\n deleteProperty(target, prop) {\n if (prop in target) {\n return delete target[prop];\n }\n return false;\n },\n};\n\nexport type CarboniumType<T extends HTMLElement = HTMLElement> =\n CarboniumList<T> & T;\n\n// Interface definitions\n\ninterface CarboniumList<T extends HTMLElement> extends Array<T> {\n concat(...items: ConcatArray<T>[]): CarboniumType<T>;\n\n concat(...items: (T | ConcatArray<T>)[]): CarboniumType<T>;\n\n reverse(): CarboniumType<T>;\n\n slice(start?: number, end?: number): CarboniumType<T>;\n\n splice(start: number, deleteCount?: number): CarboniumType<T>;\n\n /* tslint:disable:unified-signatures */\n splice(start: number, deleteCount: number, ...items: T[]): CarboniumType<T>;\n\n forEach(\n callbackfn: (value: T, index: number, array: T[]) => void,\n thisArg?: any\n ): CarboniumType<T>;\n\n filter(\n callbackfn: (value: T, index: number, array: T[]) => boolean,\n thisArg?: any\n ): CarboniumType<T>;\n\n setAttribute(qualifiedName: string, value: string): CarboniumType<T>;\n\n classList: CarboniumClassList<T>;\n style: CarboniumStyleList<T>;\n}\n\ninterface CarboniumClassList<T extends HTMLElement> extends DOMTokenList {\n add(...tokens: string[]): CarboniumType<T>;\n\n remove(...tokens: string[]): CarboniumType<T>;\n\n replace(oldToken: string, newToken: string): boolean;\n\n forEach(\n callbackfn: (value: string, key: number, parent: DOMTokenList) => void,\n thisArg?: any\n ): CarboniumType<T>;\n}\n\ninterface CarboniumStyleList<T extends HTMLElement>\n extends CSSStyleDeclaration {\n removeProperty(property: string): CarboniumList<T> & string;\n\n setProperty(\n property: string,\n value: string | null,\n priority?: string\n ): CarboniumType<T>;\n}\n"],"names":["currentListNodelist","propList","proxyHandler","get","target","prop","propValue","Symbol","iterator","i","length","Reflect","document","body","Proxy","CSSStyleDeclaration","DOMTokenList","apply","thisArg","argumentsList","forEach","el","Array","prototype","hasOwnProperty","ret","retFirst","first","undefined","set","value","deleteProperty","selectors","parentNode","nodelist","DOMParser","parseFromString","firstChild","querySelectorAll"],"mappings":";;;;;K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KACXC,GAAQ,EAEZ,IAAK,MAAMN,KAAMH,EAAS,CACxB,MAAMO,EAAMd,QAAQM,MAAMb,EAAQiB,EAAIF,GAClCQ,IACFD,EAAWD,EACXE,GAAQ,EAEX,CACD,OAAmB,MAAZD,GAAgCE,MAAZF,EACvBA,EACAR,CACL,IAGIZ,EAKJK,QAAQR,IAAIC,EAAQC,EAC5B,EAGDwB,IAAG,CAACzB,EAAQC,EAAMyB,OACZ,YAAa1B,IAAYA,aAAkBW,oBAK7CJ,QAAQkB,IAAIzB,EAAQC,EAAMyB,GAJ1B1B,EAAOgB,SAASC,IACdV,QAAQkB,IAAIR,EAAIhB,EAAMyB,EAAM,KAKzB,GAGTC,eAAc,CAAC3B,EAAQC,IACjBA,KAAQD,UACIA,EAAOC,eAvJX,SACd2B,EACAC,GAEA,IAAIC,EAeJ,OAXEA,EADkB,KAAhBF,EAAU,GAEA,EACR,IAAIG,WAAYC,gBAAgBJ,EAAW,aAAanB,KAAKwB,aAKrDJ,GAAcrB,UAAU0B,iBAAiBN,GAK3C,IAAIlB,MAAqBoB,EAAUhC,EAEjD"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- Carbonium 1.2.0
2
+ Carbonium 1.2.3
3
3
  @copyright 2020 Edwin Martin
4
4
  @license MIT
5
5
  */
@@ -1 +1 @@
1
- {"version":3,"file":"bundle.min.js","sources":["../src/carbonium.ts"],"sourcesContent":["/**\n Carbonium __buildVersion__\n @copyright 2020 Edwin Martin\n @license MIT\n */\n\nexport function $<T extends HTMLElement = HTMLElement>(\n selectors: string,\n parentNode?: Document | ShadowRoot | HTMLElement\n): CarboniumType<T> {\n let nodelist: NodeListOf<T>;\n\n // If the first parameter starts with \"<\", create a DOM node\n if (selectors[0] == \"<\") {\n nodelist = <NodeListOf<T>>(\n (<unknown>[\n new DOMParser().parseFromString(selectors, \"text/html\").body.firstChild,\n ])\n );\n } else {\n // Else, do querySelectorAll\n nodelist = (parentNode || document).querySelectorAll(selectors);\n }\n\n // Wrap it in a Proxy\n return <CarboniumType<T>>(\n (<unknown>new Proxy<NodeListOf<T>>(nodelist, proxyHandler))\n );\n}\n\n// Used by style, classList and relList\n// When setting one of these, remember the elements to apply to\nlet currentListNodelist: NodeListOf<HTMLElement>;\nlet propList: \"style\" | \"classList\" | \"relList\";\n\nconst proxyHandler: ProxyHandler<NodeListOf<HTMLElement>> = {\n get(target, prop) {\n let propValue = null;\n\n // Return iterator when asked for iterator, only used in ES2015+\n if (prop == Symbol.iterator) {\n return function* () {\n for (let i = 0; i < target.length; i++) {\n yield target[i];\n }\n };\n }\n\n // Special case for style, classList and relList\n if (prop == \"style\" || prop == \"classList\" || prop == \"relList\") {\n currentListNodelist = target;\n propList = prop;\n // Matched elements can be a list of any element or an empty list\n // Use getter of, for example, document.body.style\n const propValue = Reflect.get(document.body, prop);\n return new Proxy(propValue, proxyHandler);\n }\n\n // style.setProperty, getPropertyValue…, classList.add, contains, remove…, relList…\n if (\n target instanceof CSSStyleDeclaration ||\n target instanceof DOMTokenList\n ) {\n // Matched elements can be a list of any element or an empty list\n // Use getter of, for example, document.body.style.color\n propValue = Reflect.get(document.body[propList], prop);\n\n // When getter is a function, apply it to all matched elements\n if (typeof propValue == \"function\") {\n return new Proxy<Function>(propValue, {\n apply: function (target, thisArg, argumentsList) {\n currentListNodelist.forEach((el) => {\n Reflect.apply(target, el[propList], argumentsList);\n });\n return new Proxy(currentListNodelist, proxyHandler);\n },\n });\n } else {\n return propValue;\n }\n }\n\n // Are we dealing with an Array function like forEach, map and filter?\n if (Array.prototype.hasOwnProperty(prop)) {\n const propValue = Reflect.get(Array.prototype, prop);\n if (typeof propValue == \"function\") {\n return new Proxy<Function>(propValue, {\n apply: function (target, thisArg, argumentsList) {\n const ret = Reflect.apply(target, thisArg, argumentsList);\n // When function returns undefined (like forEach),\n // return all matched elements, so calls can be chained\n // For example forEach(…).setAttribute(…)\n const newTarget = typeof ret != \"undefined\" ? ret : thisArg;\n return new Proxy(newTarget, proxyHandler);\n },\n });\n }\n }\n\n // Get property or call function on DOM elements\n if (target.length > 0) {\n // Might be DOM element specific, like input.select(),\n // so use first array element to get reference\n if (prop in target[0]) {\n propValue = Reflect.get(target[0], prop);\n }\n } else {\n // Empty list, targeted DOM element unknown,\n // use getter of document.body\n if (prop in document.body) {\n propValue = Reflect.get(document.body, prop);\n }\n }\n\n // Propagate DOM prop value\n if (propValue) {\n if (typeof propValue == \"function\") {\n return new Proxy<Function>(propValue, {\n apply: function (target, thisArg, argumentsList) {\n let retFirst = null;\n let first = true;\n // Apply on individual elements\n for (const el of thisArg) {\n const ret = Reflect.apply(target, el, argumentsList);\n if (first) {\n retFirst = ret;\n first = false;\n }\n }\n return retFirst != null && retFirst != undefined\n ? retFirst\n : thisArg;\n },\n });\n } else {\n return propValue;\n }\n }\n\n // Default\n return Reflect.get(target, prop);\n },\n\n // DOM property is set\n set(target, prop, value) {\n if (\"forEach\" in target && !(target instanceof CSSStyleDeclaration)) {\n target.forEach((el) => {\n Reflect.set(el, prop, value);\n });\n } else {\n Reflect.set(target, prop, value);\n }\n return true;\n },\n\n deleteProperty(target, prop) {\n if (prop in target) {\n return delete target[prop];\n }\n return false;\n },\n};\n\nexport type CarboniumType<T extends HTMLElement = HTMLElement> =\n CarboniumList<T> & T;\n\n// Interface definitions\n\ninterface CarboniumList<T extends HTMLElement> extends Array<T> {\n concat(...items: ConcatArray<T>[]): CarboniumType<T>;\n\n concat(...items: (T | ConcatArray<T>)[]): CarboniumType<T>;\n\n reverse(): CarboniumType<T>;\n\n slice(start?: number, end?: number): CarboniumType<T>;\n\n splice(start: number, deleteCount?: number): CarboniumType<T>;\n\n /* tslint:disable:unified-signatures */\n splice(start: number, deleteCount: number, ...items: T[]): CarboniumType<T>;\n\n forEach(\n callbackfn: (value: T, index: number, array: T[]) => void,\n thisArg?: any\n ): CarboniumType<T>;\n\n filter(\n callbackfn: (value: T, index: number, array: T[]) => boolean,\n thisArg?: any\n ): CarboniumType<T>;\n\n setAttribute(qualifiedName: string, value: string): CarboniumType<T>;\n\n classList: CarboniumClassList<T>;\n style: CarboniumStyleList<T>;\n}\n\ninterface CarboniumClassList<T extends HTMLElement> extends DOMTokenList {\n add(...tokens: string[]): CarboniumType<T>;\n\n remove(...tokens: string[]): CarboniumType<T>;\n\n replace(oldToken: string, newToken: string): boolean;\n\n forEach(\n callbackfn: (value: string, key: number, parent: DOMTokenList) => void,\n thisArg?: any\n ): CarboniumType<T>;\n}\n\ninterface CarboniumStyleList<T extends HTMLElement>\n extends CSSStyleDeclaration {\n removeProperty(property: string): CarboniumList<T> & string;\n\n setProperty(\n property: string,\n value: string | null,\n priority?: string\n ): CarboniumType<T>;\n}\n"],"names":["$","selectors","parentNode","nodelist","DOMParser","parseFromString","body","firstChild","document","querySelectorAll","Proxy","proxyHandler","currentListNodelist","propList","get","target","prop","propValue","Symbol","iterator","i","length","Reflect","CSSStyleDeclaration","DOMTokenList","apply","thisArg","argumentsList","forEach","el","Array","prototype","hasOwnProperty","ret","retFirst","first","undefined","set","value","deleteProperty"],"mappings":";;;;;SAMgBA,EACdC,EACAC,GAEA,IAAIC,EAeJ,OAXEA,EADkB,KAAhBF,EAAU,GAEA,EACR,IAAIG,WAAYC,gBAAgBJ,EAAW,aAAaK,KAAKC,aAKrDL,GAAcM,UAAUC,iBAAiBR,GAK3C,IAAIS,MAAqBP,EAAUQ,GAMjD,IAAIC,EACAC,EAEJ,MAAMF,EAAsD,CAC1DG,IAAIC,EAAQC,GACV,IAAIC,EAAY,KAGhB,GAAID,GAAQE,OAAOC,SACjB,OAAO,YACL,IAAK,IAAIC,EAAI,EAAGA,EAAIL,EAAOM,OAAQD,UAC3BL,EAAOK,IAMnB,GAAY,SAARJ,GAA2B,aAARA,GAA+B,WAARA,EAAmB,CAC/DJ,EAAsBG,EACtBF,EAAWG,EAGX,MAAMC,EAAYK,QAAQR,IAAIN,SAASF,KAAMU,GAC7C,OAAO,IAAIN,MAAMO,EAAWN,GAI9B,GACEI,aAAkBQ,qBAClBR,aAAk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UACIA,EAAOC"}
1
+ {"version":3,"file":"bundle.min.js","sources":["../src/carbonium.ts"],"sourcesContent":["/**\n Carbonium __buildVersion__\n @copyright 2020 Edwin Martin\n @license MIT\n */\n\nexport function $<T extends HTMLElement = HTMLElement>(\n selectors: string,\n parentNode?: Document | ShadowRoot | HTMLElement\n): CarboniumType<T> {\n let nodelist: NodeListOf<T>;\n\n // If the first parameter starts with \"<\", create a DOM node\n if (selectors[0] == \"<\") {\n nodelist = <NodeListOf<T>>(\n (<unknown>[\n new DOMParser().parseFromString(selectors, \"text/html\").body.firstChild,\n ])\n );\n } else {\n // Else, do querySelectorAll\n nodelist = (parentNode || document).querySelectorAll(selectors);\n }\n\n // Wrap it in a Proxy\n return <CarboniumType<T>>(\n (<unknown>new Proxy<NodeListOf<T>>(nodelist, proxyHandler))\n );\n}\n\n// Used by style, classList and relList\n// When setting one of these, remember the elements to apply to\nlet currentListNodelist: NodeListOf<HTMLElement>;\nlet propList: \"style\" | \"classList\" | \"relList\";\n\nconst proxyHandler: ProxyHandler<NodeListOf<HTMLElement>> = {\n get(target, prop) {\n let propValue = null;\n\n // Return iterator when asked for iterator, only used in ES2015+\n if (prop == Symbol.iterator) {\n return function* () {\n for (let i = 0; i < target.length; i++) {\n yield target[i];\n }\n };\n }\n\n // Special case for style, classList and relList\n if (prop == \"style\" || prop == \"classList\" || prop == \"relList\") {\n currentListNodelist = target;\n propList = prop;\n // Matched elements can be a list of any element or an empty list\n // Use getter of, for example, document.body.style\n const propValue = Reflect.get(document.body, prop);\n return new Proxy(propValue, proxyHandler);\n }\n\n // style.setProperty, getPropertyValue…, classList.add, contains, remove…, relList…\n if (\n target instanceof CSSStyleDeclaration ||\n target instanceof DOMTokenList\n ) {\n // Matched elements can be a list of any element or an empty list\n // Use getter of, for example, document.body.style.color\n propValue = Reflect.get(document.body[propList], prop);\n\n // When getter is a function, apply it to all matched elements\n if (typeof propValue == \"function\") {\n return new Proxy<Function>(propValue, {\n apply: function (target, thisArg, argumentsList) {\n currentListNodelist.forEach((el) => {\n Reflect.apply(target, el[propList], argumentsList);\n });\n return new Proxy(currentListNodelist, proxyHandler);\n },\n });\n } else {\n return propValue;\n }\n }\n\n // Are we dealing with an Array function like forEach, map and filter?\n if (Array.prototype.hasOwnProperty(prop)) {\n const propValue = Reflect.get(Array.prototype, prop);\n if (typeof propValue == \"function\") {\n return new Proxy<Function>(propValue, {\n apply: function (target, thisArg, argumentsList) {\n const ret = Reflect.apply(target, thisArg, argumentsList);\n // When function returns undefined (like forEach),\n // return all matched elements, so calls can be chained\n // For example forEach(…).setAttribute(…)\n const newTarget = typeof ret != \"undefined\" ? ret : thisArg;\n return new Proxy(newTarget, proxyHandler);\n },\n });\n }\n }\n\n // Get property or call function on DOM elements\n if (target.length > 0) {\n // Might be DOM element specific, like input.select(),\n // so use first array element to get reference\n if (prop in target[0]) {\n propValue = Reflect.get(target[0], prop);\n }\n } else {\n // Empty list, targeted DOM element unknown,\n // use getter of document.body\n if (prop in document.body) {\n propValue = Reflect.get(document.body, prop);\n }\n }\n\n // Propagate DOM prop value\n if (propValue) {\n if (typeof propValue == \"function\") {\n return new Proxy<Function>(propValue, {\n apply: function (target, thisArg, argumentsList) {\n let retFirst = null;\n let first = true;\n // Apply on individual elements\n for (const el of thisArg) {\n const ret = Reflect.apply(target, el, argumentsList);\n if (first) {\n retFirst = ret;\n first = false;\n }\n }\n return retFirst != null && retFirst != undefined\n ? retFirst\n : thisArg;\n },\n });\n } else {\n return propValue;\n }\n }\n\n // Default\n return Reflect.get(target, prop);\n },\n\n // DOM property is set\n set(target, prop, value) {\n if (\"forEach\" in target && !(target instanceof CSSStyleDeclaration)) {\n target.forEach((el) => {\n Reflect.set(el, prop, value);\n });\n } else {\n Reflect.set(target, prop, value);\n }\n return true;\n },\n\n deleteProperty(target, prop) {\n if (prop in target) {\n return delete target[prop];\n }\n return false;\n },\n};\n\nexport type CarboniumType<T extends HTMLElement = HTMLElement> =\n CarboniumList<T> & T;\n\n// Interface definitions\n\ninterface CarboniumList<T extends HTMLElement> extends Array<T> {\n concat(...items: ConcatArray<T>[]): CarboniumType<T>;\n\n concat(...items: (T | ConcatArray<T>)[]): CarboniumType<T>;\n\n reverse(): CarboniumType<T>;\n\n slice(start?: number, end?: number): CarboniumType<T>;\n\n splice(start: number, deleteCount?: number): CarboniumType<T>;\n\n /* tslint:disable:unified-signatures */\n splice(start: number, deleteCount: number, ...items: T[]): CarboniumType<T>;\n\n forEach(\n callbackfn: (value: T, index: number, array: T[]) => void,\n thisArg?: any\n ): CarboniumType<T>;\n\n filter(\n callbackfn: (value: T, index: number, array: T[]) => boolean,\n thisArg?: any\n ): CarboniumType<T>;\n\n setAttribute(qualifiedName: string, value: string): CarboniumType<T>;\n\n classList: CarboniumClassList<T>;\n style: CarboniumStyleList<T>;\n}\n\ninterface CarboniumClassList<T extends HTMLElement> extends DOMTokenList {\n add(...tokens: string[]): CarboniumType<T>;\n\n remove(...tokens: string[]): CarboniumType<T>;\n\n replace(oldToken: string, newToken: string): boolean;\n\n forEach(\n callbackfn: (value: string, key: number, parent: DOMTokenList) => void,\n thisArg?: any\n ): CarboniumType<T>;\n}\n\ninterface CarboniumStyleList<T extends HTMLElement>\n extends CSSStyleDeclaration {\n removeProperty(property: string): CarboniumList<T> & string;\n\n setProperty(\n property: string,\n value: string | null,\n priority?: string\n ): CarboniumType<T>;\n}\n"],"names":["$","selectors","parentNode","nodelist","DOMParser","parseFromString","body","firstChild","document","querySelectorAll","Proxy","proxyHandler","currentListNodelist","propList","get","target","prop","propValue","Symbol","iterator","i","length","Reflect","CSSStyleDeclaration","DOMTokenList","apply","thisArg","argumentsList","forEach","el","Array","prototype","hasOwnProperty","ret","retFirst","first","undefined","set","value","deleteProperty"],"mappings":";;;;;AAMgB,SAAAA,EACdC,EACAC,GAEA,IAAIC,EAeJ,OAXEA,EADkB,KAAhBF,EAAU,GAEA,EACR,IAAIG,WAAYC,gBAAgBJ,EAAW,aAAaK,KAAKC,aAKrDL,GAAcM,UAA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,MAAO,SAAUV,EAAQW,EAASC,GAChC,IAAIO,EAAW,KACXC,GAAQ,EAEZ,IAAK,MAAMN,KAAMH,EAAS,CACxB,MAAMO,EAAMX,QAAQG,MAAMV,EAAQc,EAAIF,GAClCQ,IACFD,EAAWD,EACXE,GAAQ,EAEX,CACD,OAAmB,MAAZD,GAAgCE,MAAZF,EACvBA,EACAR,CACL,IAGIT,EAKJK,QAAQR,IAAIC,EAAQC,EAC5B,EAGDqB,IAAG,CAACtB,EAAQC,EAAMsB,OACZ,YAAavB,IAAYA,aAAkBQ,oBAK7CD,QAAQe,IAAItB,EAAQC,EAAMsB,GAJ1BvB,EAAOa,SAASC,IACdP,QAAQe,IAAIR,EAAIb,EAAMsB,EAAM,KAKzB,GAGTC,eAAc,CAACxB,EAAQC,IACjBA,KAAQD,UACIA,EAAOC"}
@@ -1,31 +1,31 @@
1
- /**
2
- Carbonium 1.2.0
3
- @copyright 2020 Edwin Martin
4
- @license MIT
5
- */
6
- export declare function $<T extends HTMLElement = HTMLElement>(selectors: string, parentNode?: Document | ShadowRoot | HTMLElement): CarboniumType<T>;
7
- export declare type CarboniumType<T extends HTMLElement = HTMLElement> = CarboniumList<T> & T;
8
- interface CarboniumList<T extends HTMLElement> extends Array<T> {
9
- concat(...items: ConcatArray<T>[]): CarboniumType<T>;
10
- concat(...items: (T | ConcatArray<T>)[]): CarboniumType<T>;
11
- reverse(): CarboniumType<T>;
12
- slice(start?: number, end?: number): CarboniumType<T>;
13
- splice(start: number, deleteCount?: number): CarboniumType<T>;
14
- splice(start: number, deleteCount: number, ...items: T[]): CarboniumType<T>;
15
- forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): CarboniumType<T>;
16
- filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): CarboniumType<T>;
17
- setAttribute(qualifiedName: string, value: string): CarboniumType<T>;
18
- classList: CarboniumClassList<T>;
19
- style: CarboniumStyleList<T>;
20
- }
21
- interface CarboniumClassList<T extends HTMLElement> extends DOMTokenList {
22
- add(...tokens: string[]): CarboniumType<T>;
23
- remove(...tokens: string[]): CarboniumType<T>;
24
- replace(oldToken: string, newToken: string): boolean;
25
- forEach(callbackfn: (value: string, key: number, parent: DOMTokenList) => void, thisArg?: any): CarboniumType<T>;
26
- }
27
- interface CarboniumStyleList<T extends HTMLElement> extends CSSStyleDeclaration {
28
- removeProperty(property: string): CarboniumList<T> & string;
29
- setProperty(property: string, value: string | null, priority?: string): CarboniumType<T>;
30
- }
31
- export {};
1
+ /**
2
+ Carbonium 1.2.3
3
+ @copyright 2020 Edwin Martin
4
+ @license MIT
5
+ */
6
+ export declare function $<T extends HTMLElement = HTMLElement>(selectors: string, parentNode?: Document | ShadowRoot | HTMLElement): CarboniumType<T>;
7
+ export type CarboniumType<T extends HTMLElement = HTMLElement> = CarboniumList<T> & T;
8
+ interface CarboniumList<T extends HTMLElement> extends Array<T> {
9
+ concat(...items: ConcatArray<T>[]): CarboniumType<T>;
10
+ concat(...items: (T | ConcatArray<T>)[]): CarboniumType<T>;
11
+ reverse(): CarboniumType<T>;
12
+ slice(start?: number, end?: number): CarboniumType<T>;
13
+ splice(start: number, deleteCount?: number): CarboniumType<T>;
14
+ splice(start: number, deleteCount: number, ...items: T[]): CarboniumType<T>;
15
+ forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): CarboniumType<T>;
16
+ filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): CarboniumType<T>;
17
+ setAttribute(qualifiedName: string, value: string): CarboniumType<T>;
18
+ classList: CarboniumClassList<T>;
19
+ style: CarboniumStyleList<T>;
20
+ }
21
+ interface CarboniumClassList<T extends HTMLElement> extends DOMTokenList {
22
+ add(...tokens: string[]): CarboniumType<T>;
23
+ remove(...tokens: string[]): CarboniumType<T>;
24
+ replace(oldToken: string, newToken: string): boolean;
25
+ forEach(callbackfn: (value: string, key: number, parent: DOMTokenList) => void, thisArg?: any): CarboniumType<T>;
26
+ }
27
+ interface CarboniumStyleList<T extends HTMLElement> extends CSSStyleDeclaration {
28
+ removeProperty(property: string): CarboniumList<T> & string;
29
+ setProperty(property: string, value: string | null, priority?: string): CarboniumType<T>;
30
+ }
31
+ export {};
package/package.json CHANGED
@@ -1,20 +1,21 @@
1
1
  {
2
2
  "name": "carbonium",
3
- "version": "1.2.1",
4
- "description": "Carbonium, for easy manipulation of the DOM",
5
- "main": "dist/bundle.iife.min.js",
3
+ "version": "1.2.3",
4
+ "description": "One kilobyte library for easy DOM manipulation",
5
+ "type": "module",
6
+ "browser": "dist/bundle.iife.min.js",
6
7
  "module": "dist/bundle.min.js",
7
8
  "types": "dist/carbonium.d.ts",
8
9
  "sideEffects": false,
9
10
  "scripts": {
10
11
  "prepare": "husky install",
11
12
  "start": "http-server -o demo/ --silent",
12
- "build": "rollup --config --sourcemap",
13
+ "build": "rollup --config --sourcemap --bundleConfigAsCjs",
13
14
  "dev": "rollup --config --sourcemap --watch",
14
15
  "release": "npm i --package-lock && npm run lint && npm test && npm run build && npm publish",
15
- "test": "karma start",
16
+ "test": "karma start karma.conf.cjs",
16
17
  "lint": "npx eslint . --ext .js,.ts",
17
- "prettier": "prettier --config .prettierrc.json src/**/*.{js,ts} --write"
18
+ "prettier": "prettier --config .prettierrc.json src/**/*.ts *.json --write"
18
19
  },
19
20
  "repository": {
20
21
  "type": "git",
@@ -48,30 +49,30 @@
48
49
  },
49
50
  "homepage": "https://github.com/edwinm/carbonium#readme",
50
51
  "devDependencies": {
51
- "@rollup/plugin-replace": "^3.0.0",
52
- "@types/mocha": "^9.0.0",
53
- "@types/node": "^17.0.1",
54
- "@typescript-eslint/eslint-plugin": "^5.7.0",
55
- "@typescript-eslint/parser": "^5.7.0",
56
- "@webcomponents/webcomponentsjs": "^2.4.4",
57
- "eslint": "^8.5.0",
58
- "eslint-config-prettier": "^8.3.0",
59
- "http-server": "^14.0.0",
60
- "husky": "^7.0.4",
61
- "karma": "^6.3.9",
52
+ "@rollup/plugin-replace": "^5.0.2",
53
+ "@rollup/plugin-terser": "^0.4.3",
54
+ "@types/mocha": "^10.0.1",
55
+ "@types/node": "^20.3.2",
56
+ "@typescript-eslint/eslint-plugin": "^5.60.1",
57
+ "@typescript-eslint/parser": "^5.60.1",
58
+ "@webcomponents/webcomponentsjs": "^2.8.0",
59
+ "eslint": "^8.43.0",
60
+ "eslint-config-prettier": "^8.8.0",
61
+ "http-server": "^14.1.1",
62
+ "husky": "^8.0.3",
63
+ "karma": "^6.4.2",
62
64
  "karma-chai": "^0.1.0",
63
- "karma-chrome-launcher": "^3.1.0",
64
- "karma-coverage": "^2.0.3",
65
- "karma-firefox-launcher": "^2.1.0",
65
+ "karma-chrome-launcher": "^3.2.0",
66
+ "karma-coverage": "^2.2.1",
67
+ "karma-firefox-launcher": "^2.1.2",
66
68
  "karma-mocha": "^2.0.1",
67
- "karma-typescript": "^5.1.0",
68
- "mocha": "^9.1.3",
69
- "prettier": "^2.1.1",
70
- "pretty-quick": "^3.0.0",
71
- "rollup": "^2.26.6",
72
- "rollup-plugin-terser": "^7.0.0",
73
- "rollup-plugin-typescript2": "^0.31.1",
74
- "tslib": "^2.0.1",
75
- "typescript": "4.4"
69
+ "karma-typescript": "^5.5.4",
70
+ "mocha": "^10.2.0",
71
+ "prettier": "^2.8.8",
72
+ "pretty-quick": "^3.1.3",
73
+ "rollup": "^3.25.3",
74
+ "rollup-plugin-typescript2": "^0.35.0",
75
+ "tslib": "^2.6.0",
76
+ "typescript": "5.1"
76
77
  }
77
78
  }