@oscarpalmer/toretto 0.15.1 → 0.17.0

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.
@@ -42,7 +42,7 @@ function isEmptyNonBooleanAttribute(attribute) {
42
42
  }
43
43
  function isInvalidBooleanAttribute(attribute) {
44
44
  if (!booleanAttributes.includes(attribute.name)) {
45
- return true;
45
+ return false;
46
46
  }
47
47
  const normalised = attribute.value.toLowerCase().trim();
48
48
  return !(normalised.length === 0 || normalised === attribute.name);
package/dist/attribute.js CHANGED
@@ -40,7 +40,7 @@ function isEmptyNonBooleanAttribute(attribute) {
40
40
  }
41
41
  function isInvalidBooleanAttribute(attribute) {
42
42
  if (!booleanAttributes.includes(attribute.name)) {
43
- return true;
43
+ return false;
44
44
  }
45
45
  const normalised = attribute.value.toLowerCase().trim();
46
46
  return !(normalised.length === 0 || normalised === attribute.name);
@@ -122,8 +122,7 @@ function isHidden(item) {
122
122
  }
123
123
  function isInert(item) {
124
124
  return (item.element.inert ?? false) || /^(|true)$/i.test(item.element.getAttribute("inert")) || item.element.parentElement != null && isInert({
125
- element: item.element.parentElement,
126
- tabIndex: -1
125
+ element: item.element.parentElement
127
126
  });
128
127
  }
129
128
  function isNotTabbable(item) {
package/dist/focusable.js CHANGED
@@ -120,8 +120,7 @@ function isHidden(item) {
120
120
  }
121
121
  function isInert(item) {
122
122
  return (item.element.inert ?? false) || /^(|true)$/i.test(item.element.getAttribute("inert")) || item.element.parentElement != null && isInert({
123
- element: item.element.parentElement,
124
- tabIndex: -1
123
+ element: item.element.parentElement
125
124
  });
126
125
  }
127
126
  function isNotTabbable(item) {
package/dist/sanitise.cjs CHANGED
@@ -24,7 +24,9 @@ function sanitiseNodes(nodes, options) {
24
24
  if (node instanceof Element) {
25
25
  sanitiseAttributes(node, [...node.attributes], options);
26
26
  }
27
- sanitiseNodes([...node.childNodes], options);
27
+ if (node.hasChildNodes()) {
28
+ sanitiseNodes([...node.childNodes], options);
29
+ }
28
30
  }
29
31
  return nodes;
30
32
  }
package/dist/sanitise.js CHANGED
@@ -22,7 +22,9 @@ function sanitiseNodes(nodes, options) {
22
22
  if (node instanceof Element) {
23
23
  sanitiseAttributes(node, [...node.attributes], options);
24
24
  }
25
- sanitiseNodes([...node.childNodes], options);
25
+ if (node.hasChildNodes()) {
26
+ sanitiseNodes([...node.childNodes], options);
27
+ }
26
28
  }
27
29
  return nodes;
28
30
  }
package/package.json CHANGED
@@ -4,19 +4,19 @@
4
4
  "url": "https://oscarpalmer.se"
5
5
  },
6
6
  "dependencies": {
7
- "@oscarpalmer/atoms": "^0.77"
7
+ "@oscarpalmer/atoms": "^0.82"
8
8
  },
9
9
  "description": "A collection of badass DOM utilities.",
10
10
  "devDependencies": {
11
11
  "@biomejs/biome": "^1.9",
12
- "@types/node": "^22.7",
13
- "@vitest/coverage-istanbul": "^2.1",
12
+ "@types/node": "^22.13",
13
+ "@vitest/coverage-istanbul": "^3",
14
14
  "dts-bundle-generator": "^9.5",
15
15
  "glob": "^11",
16
- "happy-dom": "^15.7",
17
- "typescript": "^5.6",
18
- "vite": "^5.4",
19
- "vitest": "^2.1"
16
+ "happy-dom": "^16.8",
17
+ "typescript": "^5.7",
18
+ "vite": "^6",
19
+ "vitest": "^3"
20
20
  },
21
21
  "exports": {
22
22
  ".": {
@@ -128,15 +128,8 @@
128
128
  }
129
129
  }
130
130
  },
131
- "files": [
132
- "dist",
133
- "src",
134
- "types"
135
- ],
136
- "keywords": [
137
- "dom",
138
- "utility"
139
- ],
131
+ "files": ["dist", "src", "types"],
132
+ "keywords": ["dom", "utility"],
140
133
  "license": "MIT",
141
134
  "main": "dist/index.cjs",
142
135
  "module": "dist/index.js",
@@ -150,10 +143,10 @@
150
143
  "compile": "npx vite build && npm run types",
151
144
  "clean": "rm -rf ./dist && rm -rf ./types && rm -f ./tsconfig.tsbuildinfo",
152
145
  "test": "npx vitest --coverage",
153
- "types": "npx tsc && npx dts-bundle-generator --config ./dts.config.ts --silent",
146
+ "types": "npx tsc && npx dts-bundle-generator --config ./dts.config.cts --silent",
154
147
  "watch": "npx vite build --watch"
155
148
  },
156
149
  "type": "module",
157
150
  "types": "types/index.d.cts",
158
- "version": "0.15.1"
151
+ "version": "0.17.0"
159
152
  }
package/src/attribute.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import {isPlainObject} from '@oscarpalmer/atoms/is';
2
2
  import type {PlainObject} from '@oscarpalmer/atoms/models';
3
3
  import {getString} from '@oscarpalmer/atoms/string';
4
- import type {Attribute, HTMLOrSVGElement, Property} from '~/models';
4
+ import type {Attribute, HTMLOrSVGElement, Property} from './models';
5
5
 
6
6
  /**
7
7
  * List of boolean attributes
@@ -74,7 +74,7 @@ export function isInvalidBooleanAttribute(
74
74
  attribute: Attribute<string>,
75
75
  ): boolean {
76
76
  if (!booleanAttributes.includes(attribute.name)) {
77
- return true;
77
+ return false;
78
78
  }
79
79
 
80
80
  const normalised = attribute.value.toLowerCase().trim();
package/src/data.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type {PlainObject} from '@oscarpalmer/atoms/models';
2
2
  import {parse} from '@oscarpalmer/atoms/string';
3
3
  import {setElementValues, updateElementValue} from './internal/element-value';
4
- import type {HTMLOrSVGElement} from '~/models';
4
+ import type {HTMLOrSVGElement} from './models';
5
5
 
6
6
  /**
7
7
  * Get data values from an element
package/src/event.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import {isPlainObject} from '@oscarpalmer/atoms/is';
2
- import {getBoolean} from '~/internal/get-value';
3
- import type {EventPosition, RemovableEventListener} from '~/models';
2
+ import {getBoolean} from './internal/get-value';
3
+ import type {EventPosition, RemovableEventListener} from './models';
4
4
 
5
5
  function createDispatchOptions(options: EventInit): EventInit {
6
6
  return {
package/src/find.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type {Selector} from '~/models';
1
+ import type {Selector} from './models';
2
2
 
3
3
  /**
4
4
  * Get the distance between two elements _(i.e., the amount of nodes of between them)_
package/src/html.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import {isPlainObject} from '@oscarpalmer/atoms/is';
2
- import {type SanitiseOptions, sanitise} from '~/sanitise';
2
+ import {type SanitiseOptions, sanitise} from './sanitise';
3
3
 
4
4
  const templates: Record<string, HTMLTemplateElement> = {};
5
5
 
package/src/index.ts CHANGED
@@ -1,10 +1,10 @@
1
- export * from '~/attribute';
2
- export * from '~/data';
3
- export * from '~/event';
4
- export * from '~/find';
5
- export * from '~/focusable';
6
- export * from '~/html';
7
- export * from '~/is';
8
- export * from '~/models';
9
- export * from '~/sanitise';
10
- export * from '~/style';
1
+ export * from './attribute';
2
+ export * from './data';
3
+ export * from './event';
4
+ export * from './find';
5
+ export * from './focusable';
6
+ export * from './html';
7
+ export * from './is';
8
+ export * from './models';
9
+ export * from './sanitise';
10
+ export * from './style';
@@ -1,6 +1,6 @@
1
1
  import {isNullableOrWhitespace, isPlainObject} from '@oscarpalmer/atoms/is';
2
2
  import type {PlainObject} from '@oscarpalmer/atoms/models';
3
- import type {HTMLOrSVGElement} from '~/models';
3
+ import type {HTMLOrSVGElement} from '../models';
4
4
 
5
5
  export function setElementValues(
6
6
  element: HTMLOrSVGElement,
package/src/is.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type {HTMLOrSVGElement} from '~/models';
1
+ import type {HTMLOrSVGElement} from './models';
2
2
 
3
3
  /**
4
4
  * Is the value a child node?
package/src/sanitise.ts CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  isBadAttribute,
3
3
  isEmptyNonBooleanAttribute,
4
4
  isInvalidBooleanAttribute,
5
- } from '~/attribute';
5
+ } from './attribute';
6
6
 
7
7
  export type SanitiseOptions = {
8
8
  /**
@@ -56,7 +56,9 @@ function sanitiseNodes(nodes: Node[], options: SanitiseOptions): Node[] {
56
56
  sanitiseAttributes(node, [...node.attributes], options);
57
57
  }
58
58
 
59
- sanitiseNodes([...node.childNodes], options);
59
+ if (node.hasChildNodes()) {
60
+ sanitiseNodes([...node.childNodes], options);
61
+ }
60
62
  }
61
63
 
62
64
  return nodes;
package/src/style.ts CHANGED
@@ -1,5 +1,5 @@
1
- import {setElementValues, updateElementValue} from '~/internal/element-value';
2
- import type {HTMLOrSVGElement, TextDirection} from '~/models';
1
+ import {setElementValues, updateElementValue} from './internal/element-value';
2
+ import type {HTMLOrSVGElement, TextDirection} from './models';
3
3
 
4
4
  /**
5
5
  * Get a style from an element
@@ -1,4 +1,4 @@
1
- import type { Attribute, HTMLOrSVGElement, Property } from '~/models';
1
+ import type { Attribute, HTMLOrSVGElement, Property } from './models';
2
2
  /**
3
3
  * List of boolean attributes
4
4
  */
package/types/data.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { PlainObject } from '@oscarpalmer/atoms/models';
2
- import type { HTMLOrSVGElement } from '~/models';
2
+ import type { HTMLOrSVGElement } from './models';
3
3
  /**
4
4
  * Get data values from an element
5
5
  */
package/types/event.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { EventPosition, RemovableEventListener } from '~/models';
1
+ import type { EventPosition, RemovableEventListener } from './models';
2
2
  /**
3
3
  * Dispatch an event for a target
4
4
  */
package/types/find.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Selector } from '~/models';
1
+ import type { Selector } from './models';
2
2
  /**
3
3
  * Get the distance between two elements _(i.e., the amount of nodes of between them)_
4
4
  */
package/types/html.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type SanitiseOptions } from '~/sanitise';
1
+ import { type SanitiseOptions } from './sanitise';
2
2
  /**
3
3
  * - Create nodes from a string of _HTML_ or a template element
4
4
  * - If `value` looks like an _ID_, it will be treated as an _ID_ before falling back to being treated as _HTML_
package/types/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- export * from '~/attribute';
2
- export * from '~/data';
3
- export * from '~/event';
4
- export * from '~/find';
5
- export * from '~/focusable';
6
- export * from '~/html';
7
- export * from '~/is';
8
- export * from '~/models';
9
- export * from '~/sanitise';
10
- export * from '~/style';
1
+ export * from './attribute';
2
+ export * from './data';
3
+ export * from './event';
4
+ export * from './find';
5
+ export * from './focusable';
6
+ export * from './html';
7
+ export * from './is';
8
+ export * from './models';
9
+ export * from './sanitise';
10
+ export * from './style';
@@ -1,4 +1,4 @@
1
1
  import type { PlainObject } from '@oscarpalmer/atoms/models';
2
- import type { HTMLOrSVGElement } from '~/models';
2
+ import type { HTMLOrSVGElement } from '../models';
3
3
  export declare function setElementValues(element: HTMLOrSVGElement, first: PlainObject | string, second: unknown, callback: (element: HTMLOrSVGElement, key: string, value: unknown) => void): void;
4
4
  export declare function updateElementValue(element: HTMLOrSVGElement, key: string, value: unknown, set: (key: string, value: string) => void, remove: (key: string) => void, json: boolean): void;
package/types/is.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { HTMLOrSVGElement } from '~/models';
1
+ import type { HTMLOrSVGElement } from './models';
2
2
  /**
3
3
  * Is the value a child node?
4
4
  */
package/types/style.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { HTMLOrSVGElement, TextDirection } from '~/models';
1
+ import type { HTMLOrSVGElement, TextDirection } from './models';
2
2
  /**
3
3
  * Get a style from an element
4
4
  */