browser-extension-utils 0.1.12 → 0.1.14

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 (2) hide show
  1. package/lib/index.js +11 -1
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -4,6 +4,13 @@ export const win = window
4
4
 
5
5
  export const uniq = (array) => [...new Set(array)]
6
6
 
7
+ // Polyfill for String.prototype.replaceAll()
8
+ // eslint-disable-next-line no-use-extend-native/no-use-extend-native
9
+ if (typeof String.prototype.replaceAll !== "function") {
10
+ // eslint-disable-next-line no-use-extend-native/no-use-extend-native, no-extend-native
11
+ String.prototype.replaceAll = String.prototype.replace
12
+ }
13
+
7
14
  export const toCamelCase = function (text) {
8
15
  return text.replaceAll(/^([A-Z])|[\s-_](\w)/g, function (match, p1, p2) {
9
16
  if (p2) return p2.toUpperCase()
@@ -99,8 +106,10 @@ export const setAttributes = (element, attributes) => {
99
106
  continue
100
107
  }
101
108
 
102
- if (/^(value|textContent|innerText|innerHTML)$/.test(name)) {
109
+ if (/^(value|textContent|innerText)$/.test(name)) {
103
110
  element[name] = value
111
+ } else if (/^(innerHTML)$/.test(name)) {
112
+ element[name] = createHTML(value)
104
113
  } else if (name === "style") {
105
114
  setStyle(element, value, true)
106
115
  } else if (/on\w+/.test(name)) {
@@ -249,6 +258,7 @@ export const throttle = (func, interval) => {
249
258
  return handler
250
259
  }
251
260
 
261
+ // Polyfill for Object.hasOwn()
252
262
  if (typeof Object.hasOwn !== "function") {
253
263
  Object.hasOwn = (instance, prop) =>
254
264
  Object.prototype.hasOwnProperty.call(instance, prop)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browser-extension-utils",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "description": "Utilities for developing browser extensions and userscripts",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",