browser-extension-utils 0.1.11 → 0.1.13

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
@@ -164,5 +164,5 @@ export function parseInt10(
164
164
  defaultValue?: number
165
165
  ): number
166
166
 
167
- // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-redundant-type-constituents
168
- export function createHTML(html: string): TrustedHTML | string
167
+ // eslint-disable-next-line @typescript-eslint/naming-convention
168
+ export function createHTML(html: string): string
package/lib/index.js CHANGED
@@ -5,7 +5,7 @@ export const win = window
5
5
  export const uniq = (array) => [...new Set(array)]
6
6
 
7
7
  export const toCamelCase = function (text) {
8
- return text.replace(/^([A-Z])|[\s-_](\w)/g, function (match, p1, p2) {
8
+ return text.replaceAll(/^([A-Z])|[\s-_](\w)/g, function (match, p1, p2) {
9
9
  if (p2) return p2.toUpperCase()
10
10
  return p1.toLowerCase()
11
11
  })
@@ -99,8 +99,10 @@ export const setAttributes = (element, attributes) => {
99
99
  continue
100
100
  }
101
101
 
102
- if (/^(value|textContent|innerText|innerHTML)$/.test(name)) {
102
+ if (/^(value|textContent|innerText)$/.test(name)) {
103
103
  element[name] = value
104
+ } else if (/^(innerHTML)$/.test(name)) {
105
+ element[name] = createHTML(value)
104
106
  } else if (name === "style") {
105
107
  setStyle(element, value, true)
106
108
  } else if (/on\w+/.test(name)) {
@@ -204,7 +206,8 @@ export const toStyleMap = (styleText) => {
204
206
  return map
205
207
  }
206
208
 
207
- export const noStyleSpace = (text) => text.replace(/\s*([^\w-+%!])\s*/gm, "$1")
209
+ export const noStyleSpace = (text) =>
210
+ text.replaceAll(/\s*([^\w-+%!])\s*/gm, "$1")
208
211
 
209
212
  export const createSetStyle = (styleText) => {
210
213
  const styleMap = toStyleMap(styleText)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browser-extension-utils",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "Utilities for developing browser extensions and userscripts",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -30,7 +30,7 @@
30
30
  "homepage": "https://github.com/PipecraftNet/browser-extension-utils#readme",
31
31
  "devDependencies": {
32
32
  "prettier": "^2.8.8",
33
- "xo": "^0.54.2"
33
+ "xo": "^0.55.0"
34
34
  },
35
35
  "files": [
36
36
  "lib/",