@thednp/shorty 2.0.0-alpha20 → 2.0.0-alpha21
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/dist/shorty.cjs +1 -1
- package/dist/shorty.cjs.map +1 -1
- package/dist/shorty.d.ts +2 -2
- package/dist/shorty.js +1 -1
- package/dist/shorty.js.map +1 -1
- package/dist/shorty.mjs +1 -1
- package/dist/shorty.mjs.map +1 -1
- package/package.json +1 -1
- package/src/misc/createElement.ts +3 -3
- package/src/misc/createElementNS.ts +5 -5
package/package.json
CHANGED
|
@@ -13,11 +13,11 @@ import ObjectAssign from './ObjectAssign';
|
|
|
13
13
|
* @param param `tagName` or object
|
|
14
14
|
* @return a new `HTMLElement`
|
|
15
15
|
*/
|
|
16
|
-
const createElement = (param?: string | Partial<
|
|
16
|
+
const createElement = <T extends HTMLElement>(param?: string | Partial<T>): T | undefined => {
|
|
17
17
|
if (!param) return undefined;
|
|
18
18
|
|
|
19
19
|
if (isString(param)) {
|
|
20
|
-
return getDocument().createElement(param);
|
|
20
|
+
return getDocument().createElement(param) as T;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
const { tagName } = param;
|
|
@@ -28,7 +28,7 @@ const createElement = (param?: string | Partial<HTMLElement>): HTMLElement | und
|
|
|
28
28
|
const attr = { ...(param as Record<string, unknown>) };
|
|
29
29
|
delete attr.tagName;
|
|
30
30
|
|
|
31
|
-
return ObjectAssign(newElement, attr);
|
|
31
|
+
return ObjectAssign(newElement, attr) as unknown as T;
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
export default createElement;
|
|
@@ -16,14 +16,14 @@ import isString from '../is/isString';
|
|
|
16
16
|
* @param param `tagName` or object
|
|
17
17
|
* @return a new `HTMLElement`
|
|
18
18
|
*/
|
|
19
|
-
const createElementNS = (
|
|
19
|
+
const createElementNS = <T extends HTMLElement>(
|
|
20
20
|
ns: string,
|
|
21
|
-
param?: string | Partial<
|
|
22
|
-
):
|
|
21
|
+
param?: string | Partial<T>,
|
|
22
|
+
): T | undefined => {
|
|
23
23
|
if (!ns || !param) return undefined;
|
|
24
24
|
|
|
25
25
|
if (isString(param)) {
|
|
26
|
-
return getDocument().createElementNS(ns, param) as
|
|
26
|
+
return getDocument().createElementNS(ns, param) as T;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
const { tagName } = param;
|
|
@@ -34,7 +34,7 @@ const createElementNS = (
|
|
|
34
34
|
const attr = { ...(param as Record<string, unknown>) };
|
|
35
35
|
delete attr.tagName;
|
|
36
36
|
|
|
37
|
-
return ObjectAssign(newElement, attr);
|
|
37
|
+
return ObjectAssign(newElement, attr) as unknown as T;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
export default createElementNS;
|