aprog 1.8.5 → 1.8.6

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.
Files changed (3) hide show
  1. package/index.js +5 -1
  2. package/package.json +1 -1
  3. package/src/html.js +24 -0
package/index.js CHANGED
@@ -14,4 +14,8 @@ export { mathInput, autoPPI } from './src/math.js';
14
14
  export { cookie, storage, cacheKey } from './src/storage.js';
15
15
  export { paginate, parseData } from './src/paginate.js';
16
16
  export { saveItem, loadItem, setSecretKey } from './src/secretStorage.js';
17
- export { pushHTMLElementPrototype, pushAfterHTMLElementPrototype, pushBeforeHTMLElementPrototype, dataHTMLElementPrototype } from './src/html.js';
17
+ export {
18
+ pushHTMLElementPrototype, pushAfterHTMLElementPrototype,
19
+ pushBeforeHTMLElementPrototype, dataHTMLElementPrototype,
20
+ toKebabCaseStringPrototype, repeatHTMLElementPrototype
21
+ } from './src/html.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aprog",
3
- "version": "1.8.5",
3
+ "version": "1.8.6",
4
4
  "description": "Допоміжна бібліотека js",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/html.js CHANGED
@@ -35,7 +35,31 @@ export function dataHTMLElementPrototype() {
35
35
  }
36
36
  }
37
37
 
38
+ export function toKebabCaseStringPrototype() {
39
+ if (!String.prototype.toKebabCase) {
40
+ String.prototype.toKebabCase = function () {
41
+ return this
42
+ .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
43
+ .replace(/([A-Z])([A-Z][a-z])/g, '$1-$2')
44
+ .toLowerCase();
45
+ };
46
+ }
47
+ }
48
+
49
+ export function repeatHTMLElementPrototype() {
50
+ if (!HTMLElement.prototype.repeat) {
51
+ HTMLElement.prototype.repeat = function (newElement) {
52
+ if (!(newElement instanceof HTMLElement)) {
53
+ throw new Error('Argument must be an HTMLElement');
54
+ }
55
+ this.replaceWith(newElement);
56
+ };
57
+ }
58
+ }
59
+
38
60
  pushHTMLElementPrototype();
39
61
  pushAfterHTMLElementPrototype();
40
62
  pushBeforeHTMLElementPrototype();
41
63
  dataHTMLElementPrototype();
64
+ toKebabCaseStringPrototype();
65
+ repeatHTMLElementPrototype();