@thednp/shorty 2.0.0-alpha10 → 2.0.0-alpha12
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/.lgtm.yml +3 -4
- package/README.md +1 -1
- package/cypress/e2e/misc.cy.ts +28 -5
- package/dist/shorty.cjs +1 -1
- package/dist/shorty.cjs.map +1 -1
- package/dist/shorty.d.ts +3 -1
- package/dist/shorty.js +1 -1
- package/dist/shorty.js.map +1 -1
- package/dist/shorty.mjs +428 -317
- package/dist/shorty.mjs.map +1 -1
- package/package.json +7 -9
- package/src/index.ts +3 -0
- package/src/misc/createElement.ts +2 -8
- package/src/misc/createElementNS.ts +4 -9
- package/tsconfig.json +3 -3
- package/vite.config.ts +2 -0
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thednp/shorty",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"type": "module",
|
|
3
|
+
"version": "2.0.0alpha12",
|
|
5
4
|
"description": "TypeScript shorties for the web",
|
|
6
5
|
"source": "src/index.ts",
|
|
7
6
|
"main": "dist/shorty.js",
|
|
@@ -40,20 +39,19 @@
|
|
|
40
39
|
},
|
|
41
40
|
"homepage": "https://github.com/thednp/shorty",
|
|
42
41
|
"devDependencies": {
|
|
43
|
-
"@bahmutov/cypress-esbuild-preprocessor": "^2.1.
|
|
42
|
+
"@bahmutov/cypress-esbuild-preprocessor": "^2.1.5",
|
|
44
43
|
"@cypress/code-coverage": "^3.10.0",
|
|
45
44
|
"@types/istanbul-lib-instrument": "^1.7.4",
|
|
46
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
47
|
-
"@typescript-eslint/parser": "^5.
|
|
45
|
+
"@typescript-eslint/eslint-plugin": "^5.47.1",
|
|
46
|
+
"@typescript-eslint/parser": "^5.47.1",
|
|
48
47
|
"cypress": "^12.4.1",
|
|
49
48
|
"dts-bundle-generator": "^7.2.0",
|
|
50
|
-
"eslint": "^8.
|
|
51
|
-
"eslint-plugin-jsdoc": "^39.
|
|
49
|
+
"eslint": "^8.30.0",
|
|
50
|
+
"eslint-plugin-jsdoc": "^39.6.4",
|
|
52
51
|
"eslint-plugin-prefer-arrow": "^1.2.3",
|
|
53
52
|
"eslint-plugin-prettier": "^4.2.1",
|
|
54
53
|
"istanbul-lib-coverage": "^3.2.0",
|
|
55
|
-
"istanbul-lib-instrument": "^5.2.
|
|
56
|
-
"ncp": "^2.0.0",
|
|
54
|
+
"istanbul-lib-instrument": "^5.2.1",
|
|
57
55
|
"nyc": "^15.1.0",
|
|
58
56
|
"prettier": "^2.8.3",
|
|
59
57
|
"rimraf": "^3.0.2",
|
package/src/index.ts
CHANGED
|
@@ -249,6 +249,8 @@ import getElementsByTagName from './selectors/getElementsByTagName';
|
|
|
249
249
|
import getElementsByClassName from './selectors/getElementsByClassName';
|
|
250
250
|
import matches from './selectors/matches';
|
|
251
251
|
|
|
252
|
+
import { version } from '../package.json';
|
|
253
|
+
|
|
252
254
|
export {
|
|
253
255
|
ariaChecked,
|
|
254
256
|
ariaDescription,
|
|
@@ -468,4 +470,5 @@ export {
|
|
|
468
470
|
setAttributeNS,
|
|
469
471
|
removeAttribute,
|
|
470
472
|
removeAttributeNS,
|
|
473
|
+
version,
|
|
471
474
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import isString from '../is/isString';
|
|
2
|
-
import setAttribute from '../attr/setAttribute';
|
|
3
2
|
import getDocument from '../get/getDocument';
|
|
4
|
-
import
|
|
3
|
+
import ObjectAssign from './ObjectAssign';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* Shortie for `document.createElement` method
|
|
@@ -29,12 +28,7 @@ const createElement = (param?: string | Partial<HTMLElement>): HTMLElement | und
|
|
|
29
28
|
const attr = { ...(param as Record<string, unknown>) };
|
|
30
29
|
delete attr.tagName;
|
|
31
30
|
|
|
32
|
-
|
|
33
|
-
if (isString(key as string) && isString(value as string)) {
|
|
34
|
-
setAttribute(newElement, key as string, value as string);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
return newElement;
|
|
31
|
+
return ObjectAssign(newElement, attr);
|
|
38
32
|
};
|
|
39
33
|
|
|
40
34
|
export default createElement;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import getDocument from '../get/getDocument';
|
|
2
|
-
import
|
|
3
|
-
import setAttribute from '../attr/setAttribute';
|
|
2
|
+
import ObjectAssign from './ObjectAssign';
|
|
4
3
|
import isString from '../is/isString';
|
|
5
4
|
|
|
6
5
|
/**
|
|
@@ -8,6 +7,8 @@ import isString from '../is/isString';
|
|
|
8
7
|
* which allows you to create a new `HTMLElement` for a given `tagName`
|
|
9
8
|
* or based on an object with specific non-readonly attributes with string values:
|
|
10
9
|
* `id`, `className`, `textContent`, `style`, etc.
|
|
10
|
+
* Note: some elements resulted from this function call may not be compatible with
|
|
11
|
+
* some attributes.
|
|
11
12
|
*
|
|
12
13
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Document/createElementNS
|
|
13
14
|
*
|
|
@@ -33,13 +34,7 @@ const createElementNS = (
|
|
|
33
34
|
const attr = { ...(param as Record<string, unknown>) };
|
|
34
35
|
delete attr.tagName;
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
if (isString(key as string) && isString(value as string)) {
|
|
38
|
-
setAttribute(newElement, key as string, value as string);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
return newElement;
|
|
37
|
+
return ObjectAssign(newElement, attr);
|
|
43
38
|
};
|
|
44
39
|
|
|
45
40
|
export default createElementNS;
|
package/tsconfig.json
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"lib": ["DOM", "ESNext", "DOM.Iterable"],
|
|
5
5
|
"types": ["vite", "vite/client", "cypress"],
|
|
6
|
-
// "rootDir": "./src",
|
|
7
6
|
"rootDir": "./",
|
|
8
7
|
"baseUrl": "./",
|
|
9
8
|
"module": "ESNext",
|
|
@@ -23,8 +22,9 @@
|
|
|
23
22
|
"removeComments": false,
|
|
24
23
|
"allowSyntheticDefaultImports": true,
|
|
25
24
|
"noEmit": true,
|
|
26
|
-
"checkJs": true
|
|
25
|
+
"checkJs": true,
|
|
26
|
+
"skipLibCheck": true // allows dts-bundle-generator to import from package.json
|
|
27
27
|
},
|
|
28
28
|
"include": ["src/*", "src/**/*"],
|
|
29
|
-
"exclude": ["node_modules", "experiments", "coverage", ],
|
|
29
|
+
"exclude": ["node_modules", "experiments", "coverage", "dist"],
|
|
30
30
|
}
|