carbonium 1.0.1 → 1.2.1
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 +25 -10
- package/dist/bundle.iife.min.js +2 -2
- package/dist/bundle.iife.min.js.map +1 -1
- package/dist/bundle.min.js +2 -2
- package/dist/bundle.min.js.map +1 -1
- package/dist/carbonium.d.ts +2 -2
- package/package.json +19 -22
- package/src/carbonium.ts +10 -5
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
 [](https://coveralls.io/github/edwinm/carbonium?branch=master) [](https://www.codefactor.io/repository/github/edwinm/carbonium) [ [](https://coveralls.io/github/edwinm/carbonium?branch=master) [](https://www.codefactor.io/repository/github/edwinm/carbonium) [](https://bundlephobia.com/result?p=carbonium) [](https://www.npmjs.com/package/carbonium) [](https://github.com/edwinm/carbonium/blob/master/LICENSE)
|
|
2
2
|
|
|
3
3
|
[](#readme)
|
|
4
4
|
|
|
@@ -45,25 +45,41 @@ If you don't want to install or use a bundler like webpack or rollup.js, you can
|
|
|
45
45
|
|
|
46
46
|
```javascript
|
|
47
47
|
const { $ } = await import(
|
|
48
|
-
"https://cdn.jsdelivr.net/npm/carbonium/dist/bundle.min.js"
|
|
48
|
+
"https://cdn.jsdelivr.net/npm/carbonium@1/dist/bundle.min.js"
|
|
49
49
|
);
|
|
50
50
|
```
|
|
51
51
|
|
|
52
52
|
## API
|
|
53
53
|
|
|
54
|
+
### Select elements
|
|
55
|
+
|
|
54
56
|
### `$(selector [, parentNode])`
|
|
55
57
|
|
|
56
|
-
|
|
58
|
+
#### Parameters
|
|
59
|
+
|
|
60
|
+
| Name | Type | Description |
|
|
61
|
+
| ---------- | ------------------------------ | -------------------------------------------------------------------------- |
|
|
62
|
+
| selector | string | Selector to select elements |
|
|
63
|
+
| parentNode | Document \| Element (optional) | Document or element in which to apply the selector, defaults to `document` |
|
|
64
|
+
|
|
65
|
+
#### Returns
|
|
57
66
|
|
|
58
|
-
|
|
67
|
+
An array of the matched elements, which can also be accessed as a single element.
|
|
68
|
+
|
|
69
|
+
### Create element
|
|
59
70
|
|
|
60
71
|
### `$(html [, parentNode])`
|
|
61
72
|
|
|
62
|
-
|
|
73
|
+
#### Parameters
|
|
74
|
+
|
|
75
|
+
| Name | Type | Description |
|
|
76
|
+
| ---------- | ------------------------------ | -------------------------------------------------------------------------- |
|
|
77
|
+
| html | string | HTML of element to create, starting with "<" |
|
|
78
|
+
| parentNode | Document \| Element (optional) | Document or element in which to apply the selector, defaults to `document` |
|
|
63
79
|
|
|
64
|
-
|
|
80
|
+
#### Returns
|
|
65
81
|
|
|
66
|
-
|
|
82
|
+
An array with one created element.
|
|
67
83
|
|
|
68
84
|
## TypeScript
|
|
69
85
|
|
|
@@ -77,9 +93,8 @@ $<HTMLInputElement>("input, select, button").disabled = true;
|
|
|
77
93
|
|
|
78
94
|
## Why?
|
|
79
95
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
On the other side, using native DOM and writing `document.querySelectorAll(selector)` each time you want to do some DOM operations will become tedious.
|
|
96
|
+
You might find most frameworks are quite bulky and bad for performance ([1](https://css-tricks.com/radeventlistener-a-tale-of-client-side-framework-performance/)).
|
|
97
|
+
On the other side, you might find using native DOM and writing `document.querySelectorAll(selector)` each time you want to do some DOM operations to become tedious.
|
|
83
98
|
You can write your own helper function, but that only takes part of the pain away.
|
|
84
99
|
|
|
85
100
|
Carbonium seeks to find the sweet spot between using a framework and using the native DOM.
|
package/dist/bundle.iife.min.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var carbonium=function(e){"use strict";
|
|
2
2
|
/**
|
|
3
|
-
Carbonium 1.0
|
|
3
|
+
Carbonium 1.2.0
|
|
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)};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}({});
|
|
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}({});
|
|
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\nexport type CarboniumType<T extends HTMLElement = HTMLElement>
|
|
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,GAGzB,mBAAbC,EACF,IAAIQ,MAAgBR,EAAW,CACpCW,MAAO,SAAUb,EAAQc,EAASC,GAIhC,OAHAnB,EAAoBoB,SAASC,IAC3BV,QAAQM,MAAMb,EAAQiB,EAAGpB,GAAWkB,MAE/B,IAAIL,MAAMd,EAAqBE,MAInCI,EAKX,GAAIgB,MAAMC,UAAUC,eAAenB,GAAO,CACxC,MAAMC,EAAYK,QAAQR,IAAImB,MAAMC,UAAWlB,GAC/C,GAAwB,mBAAbC,EACT,OAAO,IAAIQ,MAAgBR,EAAW,CACpCW,MAAO,SAAUb,EAAQc,EAASC,GAChC,MAAMM,EAAMd,QAAQM,MAAMb,EAAQc,EAASC,GAK3C,OAAO,IAAIL,WADqB,IAAPW,EAAqBA,EAAMP,EACxBhB,MAsBpC,OAfIE,EAAOM,OAAS,EAGdL,KAAQD,EAAO,KACjBE,EAAYK,QAAQR,IAAIC,EAAO,GAAIC,IAKjCA,KAAQO,SAASC,OACnBP,EAAYK,QAAQR,IAAIS,SAASC,KAAMR,IAKvCC,EACsB,mBAAbA,EACF,IAAIQ,MAAgBR,EAAW,CACpCW,MAAO,SAAUb,EAAQc,EAASC,GAChC,IAAIO,EAAW,KACXC,GAAQ,EAEZ,IAAK,MAAMN,KAAMH,EAAS,CACxB,MAAMO,EAAMd,QAAQM,MAAMb,EAAQiB,EAAIF,GAClCQ,IACFD,EAAWD,EACXE,GAAQ,GAGZ,OAAmB,MAAZD,GAAgCE,MAAZF,EACvBA,EACAR,KAIDZ,EAKJK,QAAQR,IAAIC,EAAQC,IAI7BwB,IAAG,CAACzB,EAAQC,EAAMyB,OACZ,YAAa1B,IAAYA,aAAkBW,oBAK7CJ,QAAQkB,IAAIzB,EAAQC,EAAMyB,GAJ1B1B,EAAOgB,SAASC,IACdV,QAAQkB,IAAIR,EAAIhB,EAAMyB,OAKnB,GAGTC,eAAc,CAAC3B,EAAQC,IACjBA,KAAQD,UACIA,EAAOC,wBAtJzB2B,EACAC,GAEA,IAAIC,EAeJ,OAXEA,EADkB,KAAhBF,EAAU,GAEA,EACR,IAAIG,WAAYC,gBAAgBJ,EAAW,aAAanB,KAAKwB,aAKrDJ,GAAcrB,UAAU0B,iBAAiBN,GAK3C,IAAIlB,MAAqBoB,EAAUhC"}
|
package/dist/bundle.min.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
Carbonium 1.0
|
|
2
|
+
Carbonium 1.2.0
|
|
3
3
|
@copyright 2020 Edwin Martin
|
|
4
4
|
@license MIT
|
|
5
5
|
*/
|
|
6
|
-
function e(e,t){let n;return n="<"==e[0]?[(new DOMParser).parseFromString(e,"text/html").body.firstChild]:(t||document).querySelectorAll(e),new Proxy(n,o)}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)};export{e as $};
|
|
6
|
+
function e(e,t){let n;return n="<"==e[0]?[(new DOMParser).parseFromString(e,"text/html").body.firstChild]:(t||document).querySelectorAll(e),new Proxy(n,o)}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]};export{e as $};
|
|
7
7
|
//# sourceMappingURL=bundle.min.js.map
|
package/dist/bundle.min.js.map
CHANGED
|
@@ -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\nexport type CarboniumType<T extends HTMLElement = HTMLElement>
|
|
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,aAAkBS,aAOlB,OAHAP,EAAYK,QAAQR,IAAIN,SAASF,KAAKO,GAAWG,GAGzB,mBAAbC,EACF,IAAIP,MAAgBO,EAAW,CACpCQ,MAAO,SAAUV,EAAQW,EAASC,GAIhC,OAHAf,EAAoBgB,SAASC,IAC3BP,QAAQG,MAAMV,EAAQc,EAAGhB,GAAWc,MAE/B,IAAIjB,MAAME,EAAqBD,MAInCM,EAKX,GAAIa,MAAMC,UAAUC,eAAehB,GAAO,CACxC,MAAMC,EAAYK,QAAQR,IAAIgB,MAAMC,UAAWf,GAC/C,GAAwB,mBAAbC,EACT,OAAO,IAAIP,MAAgBO,EAAW,CACpCQ,MAAO,SAAUV,EAAQW,EAASC,GAChC,MAAMM,EAAMX,QAAQG,MAAMV,EAAQW,EAASC,GAK3C,OAAO,IAAIjB,WADqB,IAAPuB,EAAqBA,EAAMP,EACxBf,MAsBpC,OAfII,EAAOM,OAAS,EAGdL,KAAQD,EAAO,KACjBE,EAAYK,QAAQR,IAAIC,EAAO,GAAIC,IAKjCA,KAAQR,SAASF,OACnBW,EAAYK,QAAQR,IAAIN,SAASF,KAAMU,IAKvCC,EACsB,mBAAbA,EACF,IAAIP,MAAgBO,EAAW,CACpCQ,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,GAGZ,OAAmB,MAAZD,GAAgCE,MAAZF,EACvBA,EACAR,KAIDT,EAKJK,QAAQR,IAAIC,EAAQC,IAI7BqB,IAAG,CAACtB,EAAQC,EAAMsB,OACZ,YAAavB,IAAYA,aAAkBQ,oBAK7CD,QAAQe,IAAItB,EAAQC,EAAMsB,GAJ1BvB,EAAOa,SAASC,IACdP,QAAQe,IAAIR,EAAIb,EAAMsB,OAKnB,GAGTC,eAAc,CAACxB,EAAQC,IACjBA,KAAQD,UACIA,EAAOC"}
|
package/dist/carbonium.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
Carbonium 1.0
|
|
2
|
+
Carbonium 1.2.0
|
|
3
3
|
@copyright 2020 Edwin Martin
|
|
4
4
|
@license MIT
|
|
5
5
|
*/
|
|
@@ -21,7 +21,7 @@ interface CarboniumList<T extends HTMLElement> extends Array<T> {
|
|
|
21
21
|
interface CarboniumClassList<T extends HTMLElement> extends DOMTokenList {
|
|
22
22
|
add(...tokens: string[]): CarboniumType<T>;
|
|
23
23
|
remove(...tokens: string[]): CarboniumType<T>;
|
|
24
|
-
replace(oldToken: string, newToken: string):
|
|
24
|
+
replace(oldToken: string, newToken: string): boolean;
|
|
25
25
|
forEach(callbackfn: (value: string, key: number, parent: DOMTokenList) => void, thisArg?: any): CarboniumType<T>;
|
|
26
26
|
}
|
|
27
27
|
interface CarboniumStyleList<T extends HTMLElement> extends CSSStyleDeclaration {
|
package/package.json
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carbonium",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Carbonium, for easy manipulation of the DOM",
|
|
5
5
|
"main": "dist/bundle.iife.min.js",
|
|
6
6
|
"module": "dist/bundle.min.js",
|
|
7
7
|
"types": "dist/carbonium.d.ts",
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"scripts": {
|
|
10
|
+
"prepare": "husky install",
|
|
10
11
|
"start": "http-server -o demo/ --silent",
|
|
11
12
|
"build": "rollup --config --sourcemap",
|
|
12
13
|
"dev": "rollup --config --sourcemap --watch",
|
|
13
14
|
"release": "npm i --package-lock && npm run lint && npm test && npm run build && npm publish",
|
|
14
15
|
"test": "karma start",
|
|
15
|
-
"lint": "npx eslint . --ext .js,.ts"
|
|
16
|
+
"lint": "npx eslint . --ext .js,.ts",
|
|
17
|
+
"prettier": "prettier --config .prettierrc.json src/**/*.{js,ts} --write"
|
|
16
18
|
},
|
|
17
19
|
"repository": {
|
|
18
20
|
"type": "git",
|
|
@@ -29,6 +31,7 @@
|
|
|
29
31
|
"keywords": [
|
|
30
32
|
"dom",
|
|
31
33
|
"qsa",
|
|
34
|
+
"jquery",
|
|
32
35
|
"typescript",
|
|
33
36
|
"front-end",
|
|
34
37
|
"lightweight",
|
|
@@ -44,37 +47,31 @@
|
|
|
44
47
|
"url": "https://github.com/edwinm/carbonium/issues"
|
|
45
48
|
},
|
|
46
49
|
"homepage": "https://github.com/edwinm/carbonium#readme",
|
|
47
|
-
"dependencies": {},
|
|
48
50
|
"devDependencies": {
|
|
49
|
-
"@rollup/plugin-replace": "^
|
|
50
|
-
"@types/mocha": "^
|
|
51
|
-
"@types/node": "^
|
|
52
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
53
|
-
"@typescript-eslint/parser": "^
|
|
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",
|
|
54
56
|
"@webcomponents/webcomponentsjs": "^2.4.4",
|
|
55
|
-
"eslint": "^
|
|
56
|
-
"eslint-config-prettier": "^
|
|
57
|
-
"http-server": "^0.
|
|
58
|
-
"husky": "^
|
|
59
|
-
"karma": "^
|
|
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",
|
|
60
62
|
"karma-chai": "^0.1.0",
|
|
61
63
|
"karma-chrome-launcher": "^3.1.0",
|
|
62
64
|
"karma-coverage": "^2.0.3",
|
|
63
|
-
"karma-firefox-launcher": "^1.
|
|
65
|
+
"karma-firefox-launcher": "^2.1.0",
|
|
64
66
|
"karma-mocha": "^2.0.1",
|
|
65
67
|
"karma-typescript": "^5.1.0",
|
|
66
|
-
"mocha": "^
|
|
68
|
+
"mocha": "^9.1.3",
|
|
67
69
|
"prettier": "^2.1.1",
|
|
68
70
|
"pretty-quick": "^3.0.0",
|
|
69
71
|
"rollup": "^2.26.6",
|
|
70
72
|
"rollup-plugin-terser": "^7.0.0",
|
|
71
|
-
"rollup-plugin-typescript2": "^0.
|
|
73
|
+
"rollup-plugin-typescript2": "^0.31.1",
|
|
72
74
|
"tslib": "^2.0.1",
|
|
73
|
-
"typescript": "
|
|
74
|
-
},
|
|
75
|
-
"husky": {
|
|
76
|
-
"hooks": {
|
|
77
|
-
"pre-commit": "pretty-quick --staged"
|
|
78
|
-
}
|
|
75
|
+
"typescript": "4.4"
|
|
79
76
|
}
|
|
80
77
|
}
|
package/src/carbonium.ts
CHANGED
|
@@ -152,12 +152,17 @@ const proxyHandler: ProxyHandler<NodeListOf<HTMLElement>> = {
|
|
|
152
152
|
}
|
|
153
153
|
return true;
|
|
154
154
|
},
|
|
155
|
+
|
|
156
|
+
deleteProperty(target, prop) {
|
|
157
|
+
if (prop in target) {
|
|
158
|
+
return delete target[prop];
|
|
159
|
+
}
|
|
160
|
+
return false;
|
|
161
|
+
},
|
|
155
162
|
};
|
|
156
163
|
|
|
157
|
-
export type CarboniumType<T extends HTMLElement = HTMLElement> =
|
|
158
|
-
T
|
|
159
|
-
> &
|
|
160
|
-
T;
|
|
164
|
+
export type CarboniumType<T extends HTMLElement = HTMLElement> =
|
|
165
|
+
CarboniumList<T> & T;
|
|
161
166
|
|
|
162
167
|
// Interface definitions
|
|
163
168
|
|
|
@@ -196,7 +201,7 @@ interface CarboniumClassList<T extends HTMLElement> extends DOMTokenList {
|
|
|
196
201
|
|
|
197
202
|
remove(...tokens: string[]): CarboniumType<T>;
|
|
198
203
|
|
|
199
|
-
replace(oldToken: string, newToken: string):
|
|
204
|
+
replace(oldToken: string, newToken: string): boolean;
|
|
200
205
|
|
|
201
206
|
forEach(
|
|
202
207
|
callbackfn: (value: string, key: number, parent: DOMTokenList) => void,
|