browser-extension-utils 0.0.3 → 0.0.5

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/lib/index.d.ts CHANGED
@@ -1,14 +1,47 @@
1
1
  export function uniq(array: any[]): any[]
2
+
2
3
  export function toCamelCase(text: string): string
3
- export function querySelector(element, selectors?: string): HTMLElement
4
- export function querySelectorAll(element, selectors?: string): any[]
5
- export function $(element, selectors?: string): HTMLElement
6
- export function $$(element, selectors?: string): any[]
7
- export function createElement(type: string): HTMLElement
8
- export function addEventListener(element, type, listener): void
9
- export function setAttribute(element, attr, value): void
10
- export function setStyle(element, style): void
4
+
5
+ export function $(
6
+ element: HTMLElement | string,
7
+ selectors?: string
8
+ ): HTMLElement
9
+
10
+ export function querySelector(
11
+ element: HTMLElement | string,
12
+ selectors?: string
13
+ ): HTMLElement
14
+
15
+ export function $$(
16
+ element: HTMLElement | string,
17
+ selectors?: string
18
+ ): HTMLElement[]
19
+
20
+ export function querySelectorAll(
21
+ element: HTMLElement | string,
22
+ selectors?: string
23
+ ): HTMLElement[]
24
+
25
+ export function createElement(tagName: string): HTMLElement
26
+
27
+ export function addEventListener(
28
+ element: HTMLElement,
29
+ type: string | Record<string, unknown>,
30
+ listener?
31
+ ): void
32
+
33
+ export function setAttribute(
34
+ element: HTMLElement,
35
+ name: string,
36
+ value: string
37
+ ): void
38
+
39
+ export function setStyle(element, style: string | Record<string, unknown>): void
40
+
11
41
  export function toStyleMap(styleText: string): Record<string, unknown>
42
+
12
43
  export function noStyleSpace(text: string): string
44
+
13
45
  export function createSetStyle(styleText: string): setStyle
46
+
14
47
  export function isUrl(text: string): boolean
package/lib/index.js CHANGED
@@ -9,16 +9,16 @@ export const toCamelCase = function (text) {
9
9
  })
10
10
  }
11
11
 
12
- export const querySelector = (element, selectors) =>
12
+ export const $ = (element, selectors) =>
13
13
  typeof element === "object"
14
14
  ? element.querySelector(selectors)
15
15
  : doc.querySelector(element)
16
- export const querySelectorAll = (element, selectors) =>
16
+ export const $$ = (element, selectors) =>
17
17
  typeof element === "object"
18
18
  ? [...element.querySelectorAll(selectors)]
19
19
  : [...doc.querySelectorAll(element)]
20
- export const $ = querySelector
21
- export const $$ = querySelectorAll
20
+ export const querySelector = $
21
+ export const querySelectorAll = $$
22
22
 
23
23
  export const createElement = doc.createElement.bind(doc)
24
24
 
@@ -35,8 +35,8 @@ export const addEventListener = (element, type, listener) => {
35
35
  // TODO: return remover function
36
36
  }
37
37
 
38
- export const setAttribute = (element, attr, value) =>
39
- element.setAttribute(attr, value)
38
+ export const setAttribute = (element, name, value) =>
39
+ element.setAttribute(name, value)
40
40
 
41
41
  export const setStyle = (element, values) => {
42
42
  // setAttribute(element, "style", value)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browser-extension-utils",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "Utilities for developing browser extensions and userscripts",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",