@oscarpalmer/toretto 0.47.1 → 0.47.3
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/dist/aria.d.mts +1 -1
- package/dist/attribute/get.attribute.d.mts +2 -3
- package/dist/html/index.mjs +1 -1
- package/dist/index.d.mts +3 -4
- package/dist/index.mjs +1 -13
- package/dist/internal/attribute.mjs +1 -1
- package/dist/internal/element-value.mjs +1 -2
- package/package.json +1 -1
- package/src/aria.ts +1 -1
- package/src/attribute/get.attribute.ts +2 -8
- package/src/internal/element-value.ts +1 -2
package/dist/aria.d.mts
CHANGED
|
@@ -28,7 +28,7 @@ declare function getAria<Attribute extends AnyAriaAttribute>(element: Element, a
|
|
|
28
28
|
* @param element Element to get role from
|
|
29
29
|
* @returns Element role _(or `undefined`)_
|
|
30
30
|
*/
|
|
31
|
-
declare function getRole(element: Element):
|
|
31
|
+
declare function getRole(element: Element): string | undefined;
|
|
32
32
|
/**
|
|
33
33
|
* Set an _ARIA_ attribute on an element
|
|
34
34
|
*
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
//#region src/attribute/get.attribute.d.ts
|
|
2
|
-
type DataPrefixedName = `data-${string}`;
|
|
3
2
|
/**
|
|
4
3
|
* Get the value of a specific attribute from an element
|
|
5
4
|
*
|
|
@@ -8,7 +7,7 @@ type DataPrefixedName = `data-${string}`;
|
|
|
8
7
|
* @param parse Parse value? _(defaults to `true`)_
|
|
9
8
|
* @returns Attribute value _(or `undefined`)_
|
|
10
9
|
*/
|
|
11
|
-
declare function getAttribute(element: Element, name:
|
|
10
|
+
declare function getAttribute(element: Element, name: `data-${string}`, parse?: boolean): unknown;
|
|
12
11
|
/**
|
|
13
12
|
* Get the value of a specific attribute from an element
|
|
14
13
|
*
|
|
@@ -16,7 +15,7 @@ declare function getAttribute(element: Element, name: DataPrefixedName, parse?:
|
|
|
16
15
|
* @param name Attribute name
|
|
17
16
|
* @returns Attribute value _(or `undefined`)_
|
|
18
17
|
*/
|
|
19
|
-
declare function getAttribute(element: Element, name: string):
|
|
18
|
+
declare function getAttribute(element: Element, name: string): string | undefined;
|
|
20
19
|
/**
|
|
21
20
|
* Get specific attributes from an element
|
|
22
21
|
*
|
package/dist/html/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { sanitizeNodes } from "./sanitize.mjs";
|
|
2
|
-
import { isPlainObject } from "@oscarpalmer/atoms/is";
|
|
3
2
|
import { getString } from "@oscarpalmer/atoms/string";
|
|
3
|
+
import { isPlainObject } from "@oscarpalmer/atoms/is";
|
|
4
4
|
import { SizedMap } from "@oscarpalmer/atoms/sized/map";
|
|
5
5
|
//#region src/html/index.ts
|
|
6
6
|
function createHtml(value) {
|
package/dist/index.d.mts
CHANGED
|
@@ -95,7 +95,7 @@ declare function getAria<Attribute extends AnyAriaAttribute>(element: Element, a
|
|
|
95
95
|
* @param element Element to get role from
|
|
96
96
|
* @returns Element role _(or `undefined`)_
|
|
97
97
|
*/
|
|
98
|
-
declare function getRole(element: Element):
|
|
98
|
+
declare function getRole(element: Element): string | undefined;
|
|
99
99
|
/**
|
|
100
100
|
* Set an _ARIA_ attribute on an element
|
|
101
101
|
*
|
|
@@ -139,7 +139,6 @@ declare function setRole(element: Element, role?: AriaRole): void;
|
|
|
139
139
|
declare const booleanAttributes: readonly string[];
|
|
140
140
|
//#endregion
|
|
141
141
|
//#region src/attribute/get.attribute.d.ts
|
|
142
|
-
type DataPrefixedName = `data-${string}`;
|
|
143
142
|
/**
|
|
144
143
|
* Get the value of a specific attribute from an element
|
|
145
144
|
*
|
|
@@ -148,7 +147,7 @@ type DataPrefixedName = `data-${string}`;
|
|
|
148
147
|
* @param parse Parse value? _(defaults to `true`)_
|
|
149
148
|
* @returns Attribute value _(or `undefined`)_
|
|
150
149
|
*/
|
|
151
|
-
declare function getAttribute(element: Element, name:
|
|
150
|
+
declare function getAttribute(element: Element, name: `data-${string}`, parse?: boolean): unknown;
|
|
152
151
|
/**
|
|
153
152
|
* Get the value of a specific attribute from an element
|
|
154
153
|
*
|
|
@@ -156,7 +155,7 @@ declare function getAttribute(element: Element, name: DataPrefixedName, parse?:
|
|
|
156
155
|
* @param name Attribute name
|
|
157
156
|
* @returns Attribute value _(or `undefined`)_
|
|
158
157
|
*/
|
|
159
|
-
declare function getAttribute(element: Element, name: string):
|
|
158
|
+
declare function getAttribute(element: Element, name: string): string | undefined;
|
|
160
159
|
/**
|
|
161
160
|
* Get specific attributes from an element
|
|
162
161
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -110,18 +110,6 @@ function words(value) {
|
|
|
110
110
|
}
|
|
111
111
|
const EXPRESSION_WORDS = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
|
|
112
112
|
//#endregion
|
|
113
|
-
//#region node_modules/@oscarpalmer/atoms/dist/is.mjs
|
|
114
|
-
/**
|
|
115
|
-
* Is the value `undefined`, `null`, or stringified as a whitespace-only string?
|
|
116
|
-
*
|
|
117
|
-
* @param value Value to check
|
|
118
|
-
* @returns `true` if the value is nullable or matches a whitespace-only string, otherwise `false`
|
|
119
|
-
*/
|
|
120
|
-
function isNullableOrWhitespace(value) {
|
|
121
|
-
return value == null || EXPRESSION_WHITESPACE$1.test(getString(value));
|
|
122
|
-
}
|
|
123
|
-
const EXPRESSION_WHITESPACE$1 = /^\s*$/;
|
|
124
|
-
//#endregion
|
|
125
113
|
//#region node_modules/@oscarpalmer/atoms/dist/string/index.mjs
|
|
126
114
|
/**
|
|
127
115
|
* Parse a JSON string into its proper value _(or `undefined` if it fails)_
|
|
@@ -621,7 +609,7 @@ function setElementValues(element, first, second, third, callback, style) {
|
|
|
621
609
|
}
|
|
622
610
|
}
|
|
623
611
|
function updateElementValue(element, key, value, set, remove, isBoolean, json) {
|
|
624
|
-
if (
|
|
612
|
+
if (value == null) remove.call(element, key);
|
|
625
613
|
else if (!ignoreSetAttribute(element, key)) set.call(element, key, json ? JSON.stringify(value) : getString(value));
|
|
626
614
|
}
|
|
627
615
|
const CSS_VARIABLE_PREFIX$1 = "--";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { updateProperty } from "./property.mjs";
|
|
2
2
|
import { updateElementValue } from "./element-value.mjs";
|
|
3
|
-
import { isPlainObject } from "@oscarpalmer/atoms/is";
|
|
4
3
|
import { getString } from "@oscarpalmer/atoms/string";
|
|
5
4
|
import { kebabCase } from "@oscarpalmer/atoms/string/case";
|
|
5
|
+
import { isPlainObject } from "@oscarpalmer/atoms/is";
|
|
6
6
|
//#region src/internal/attribute.ts
|
|
7
7
|
function badAttributeHandler(name, value) {
|
|
8
8
|
if (typeof name !== "string" || name.trim().length === 0 || typeof value !== "string") return true;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { isAttribute } from "./attribute.mjs";
|
|
2
|
-
import { isNullableOrWhitespace } from "@oscarpalmer/atoms/is";
|
|
3
2
|
import { getString } from "@oscarpalmer/atoms/string";
|
|
4
3
|
import { kebabCase } from "@oscarpalmer/atoms/string/case";
|
|
5
4
|
//#region src/internal/element-value.ts
|
|
@@ -35,7 +34,7 @@ function setElementValues(element, first, second, third, callback, style) {
|
|
|
35
34
|
}
|
|
36
35
|
}
|
|
37
36
|
function updateElementValue(element, key, value, set, remove, isBoolean, json) {
|
|
38
|
-
if (
|
|
37
|
+
if (value == null) remove.call(element, key);
|
|
39
38
|
else if (!ignoreSetAttribute(element, key)) set.call(element, key, json ? JSON.stringify(value) : getString(value));
|
|
40
39
|
}
|
|
41
40
|
const CSS_VARIABLE_PREFIX = "--";
|
package/package.json
CHANGED
package/src/aria.ts
CHANGED
|
@@ -73,7 +73,7 @@ function getName(value: string): string {
|
|
|
73
73
|
* @param element Element to get role from
|
|
74
74
|
* @returns Element role _(or `undefined`)_
|
|
75
75
|
*/
|
|
76
|
-
export function getRole(element: Element):
|
|
76
|
+
export function getRole(element: Element): string | undefined {
|
|
77
77
|
if (element instanceof Element) {
|
|
78
78
|
return element.getAttribute('role') ?? undefined;
|
|
79
79
|
}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import {kebabCase} from '@oscarpalmer/atoms/string/case';
|
|
2
2
|
import {getAttributeValue} from '../internal/get-value';
|
|
3
3
|
|
|
4
|
-
// #region Types
|
|
5
|
-
|
|
6
|
-
type DataPrefixedName = `data-${string}`;
|
|
7
|
-
|
|
8
|
-
// #endregion
|
|
9
|
-
|
|
10
4
|
// #region Functions
|
|
11
5
|
|
|
12
6
|
/**
|
|
@@ -17,7 +11,7 @@ type DataPrefixedName = `data-${string}`;
|
|
|
17
11
|
* @param parse Parse value? _(defaults to `true`)_
|
|
18
12
|
* @returns Attribute value _(or `undefined`)_
|
|
19
13
|
*/
|
|
20
|
-
export function getAttribute(element: Element, name:
|
|
14
|
+
export function getAttribute(element: Element, name: `data-${string}`, parse?: boolean): unknown;
|
|
21
15
|
|
|
22
16
|
/**
|
|
23
17
|
* Get the value of a specific attribute from an element
|
|
@@ -26,7 +20,7 @@ export function getAttribute(element: Element, name: DataPrefixedName, parse?: b
|
|
|
26
20
|
* @param name Attribute name
|
|
27
21
|
* @returns Attribute value _(or `undefined`)_
|
|
28
22
|
*/
|
|
29
|
-
export function getAttribute(element: Element, name: string):
|
|
23
|
+
export function getAttribute(element: Element, name: string): string | undefined;
|
|
30
24
|
|
|
31
25
|
export function getAttribute(element: Element, name: string, parseValues?: boolean): unknown {
|
|
32
26
|
if (element instanceof Element && typeof name === 'string') {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {isNullableOrWhitespace} from '@oscarpalmer/atoms/is';
|
|
2
1
|
import {getString} from '@oscarpalmer/atoms/string';
|
|
3
2
|
import {kebabCase} from '@oscarpalmer/atoms/string/case';
|
|
4
3
|
import {isAttribute} from './attribute';
|
|
@@ -83,7 +82,7 @@ export function updateElementValue(
|
|
|
83
82
|
isBoolean: boolean,
|
|
84
83
|
json: boolean,
|
|
85
84
|
): void {
|
|
86
|
-
if (
|
|
85
|
+
if (value == null) {
|
|
87
86
|
remove.call(element, key);
|
|
88
87
|
} else if (!ignoreSetAttribute(element, key)) {
|
|
89
88
|
set.call(element, key, json ? JSON.stringify(value) : getString(value));
|