@shgysk8zer0/polyfills 0.0.6 → 0.0.8

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/element.js CHANGED
@@ -126,7 +126,7 @@ if (! (HTMLImageElement.prototype.decode instanceof Function)) {
126
126
  if (
127
127
  ! (Element.prototype.setHTML instanceof Function)
128
128
  && 'Sanitizer' in globalThis
129
- && globalThis.Sanitizer.sanitizeFor instanceof Function
129
+ && globalThis.Sanitizer.prototype.sanitizeFor instanceof Function
130
130
  ) {
131
131
  Element.prototype.setHTML = function setHTML(input, { sanitizer = new globalThis.Sanitizer() } = {}) {
132
132
  if (
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@shgysk8zer0/polyfills",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "private": false,
5
+ "type": "module",
5
6
  "description": "A collection of JavaScript polyfills",
6
7
  "main": "all.min.js",
7
8
  "module": "all.js",
@@ -53,6 +54,6 @@
53
54
  "eslint": "^8.40.0",
54
55
  "htmlhint": "^1.1.4",
55
56
  "http-server": "^14.1.1",
56
- "rollup": "^2.79.1"
57
+ "rollup": "^3.23.0"
57
58
  }
58
59
  }
package/url.js ADDED
@@ -0,0 +1,10 @@
1
+ import { polyfillMethod } from './utils.js';
2
+
3
+ polyfillMethod(URL, 'canParse', (str, base) => {
4
+ try {
5
+ new URL(str, base);
6
+ return true;
7
+ } catch {
8
+ return false;
9
+ }
10
+ });
package/utils.js ADDED
@@ -0,0 +1,9 @@
1
+ export function polyfillMethod(parent, name, value, {
2
+ writable = true,
3
+ enumerable = true,
4
+ configurable = true,
5
+ } = {}) {
6
+ if (! (parent[name] instanceof Function)) {
7
+ Object.defineProperty(parent, name, { value, writable, enumerable, configurable });
8
+ }
9
+ }