@oscarpalmer/toretto 0.23.0 → 0.23.1
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/package.json +1 -1
- package/src/attribute.ts +28 -28
- package/src/data.ts +5 -5
- package/src/find.ts +2 -1
- package/src/internal/element-value.ts +1 -1
- package/types/data.d.ts +1 -1
- package/types/internal/element-value.d.ts +1 -1
package/package.json
CHANGED
package/src/attribute.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type {PlainObject} from '@oscarpalmer/atoms';
|
|
1
2
|
import {isPlainObject} from '@oscarpalmer/atoms/is';
|
|
2
|
-
import type {PlainObject} from '@oscarpalmer/atoms/models';
|
|
3
3
|
import {getString} from '@oscarpalmer/atoms/string';
|
|
4
4
|
import {getAttributeValue} from './internal/get-value';
|
|
5
5
|
import {isHTMLOrSVGElement} from './is';
|
|
@@ -186,27 +186,27 @@ export function isInvalidBooleanAttribute(attribute: Attr | Attribute): boolean;
|
|
|
186
186
|
export function isInvalidBooleanAttribute(name: string, value: string): boolean;
|
|
187
187
|
|
|
188
188
|
export function isInvalidBooleanAttribute(
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
189
|
+
first: string | Attr | Attribute,
|
|
190
|
+
second?: string,
|
|
191
|
+
): boolean {
|
|
192
|
+
return validateAttribute(
|
|
193
|
+
attribute => {
|
|
194
|
+
if (attribute == null) {
|
|
195
|
+
return true;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (!booleanAttributes.includes(attribute.name)) {
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const normalized = String(attribute.value).toLowerCase().trim();
|
|
203
|
+
|
|
204
|
+
return !(normalized.length === 0 || normalized === attribute.name);
|
|
205
|
+
},
|
|
206
|
+
first,
|
|
207
|
+
second,
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
210
|
|
|
211
211
|
function isProperty(value: unknown): value is Property {
|
|
212
212
|
return (
|
|
@@ -222,9 +222,9 @@ function isProperty(value: unknown): value is Property {
|
|
|
222
222
|
* @param attribute Attribute to set
|
|
223
223
|
*/
|
|
224
224
|
export function setAttribute(
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
225
|
+
element: HTMLOrSVGElement,
|
|
226
|
+
attribute: Attr | Attribute,
|
|
227
|
+
): void;
|
|
228
228
|
|
|
229
229
|
/**
|
|
230
230
|
* Set an attribute on an element
|
|
@@ -256,9 +256,9 @@ export function setAttribute(
|
|
|
256
256
|
* @param attributes Attributes to set
|
|
257
257
|
*/
|
|
258
258
|
export function setAttributes(
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
259
|
+
element: HTMLOrSVGElement,
|
|
260
|
+
attributes: Array<Attr | Attribute>,
|
|
261
|
+
): void;
|
|
262
262
|
|
|
263
263
|
/**
|
|
264
264
|
* Set one or more attributes on an element
|
package/src/data.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {PlainObject} from '@oscarpalmer/atoms
|
|
1
|
+
import type {PlainObject} from '@oscarpalmer/atoms';
|
|
2
2
|
import {kebabCase, parse} from '@oscarpalmer/atoms/string';
|
|
3
3
|
import {setElementValues, updateElementValue} from './internal/element-value';
|
|
4
4
|
import {isHTMLOrSVGElement} from './is';
|
|
@@ -12,10 +12,10 @@ import type {HTMLOrSVGElement} from './models';
|
|
|
12
12
|
* @returns Data value
|
|
13
13
|
*/
|
|
14
14
|
export function getData(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
element: HTMLOrSVGElement,
|
|
16
|
+
key: string,
|
|
17
|
+
parse?: boolean,
|
|
18
|
+
): unknown;
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Get keyed data values from an element
|
package/src/find.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {PlainObject} from '@oscarpalmer/atoms
|
|
1
|
+
import type {PlainObject} from '@oscarpalmer/atoms';
|
|
2
2
|
import type {Selector} from './models';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -327,3 +327,4 @@ function traverse(from: Element, to: Element): number | undefined {
|
|
|
327
327
|
}
|
|
328
328
|
|
|
329
329
|
export {findElement as $, findElements as $$};
|
|
330
|
+
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type {PlainObject} from '@oscarpalmer/atoms';
|
|
1
2
|
import {isNullableOrWhitespace, isPlainObject} from '@oscarpalmer/atoms/is';
|
|
2
|
-
import type {PlainObject} from '@oscarpalmer/atoms/models';
|
|
3
3
|
import {isHTMLOrSVGElement} from '../is';
|
|
4
4
|
import type {HTMLOrSVGElement} from '../models';
|
|
5
5
|
|
package/types/data.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PlainObject } from '@oscarpalmer/atoms
|
|
1
|
+
import type { PlainObject } from '@oscarpalmer/atoms';
|
|
2
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;
|