Skip to content

Commit 2aaec6d

Browse files
committed
Support inline style declarations
1 parent 1e71a41 commit 2aaec6d

8 files changed

Lines changed: 900 additions & 1 deletion

File tree

‎.changeset/dom-inline-styles.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clack/ui': patch
3+
---
4+
5+
Add inline style declarations with shared camelCase, dashed, and setProperty access, supported CSS value parsing, and change notifications.

‎packages/ui/package.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@
4040
},
4141
"dependencies": {
4242
"@bomb.sh/tty": "catalog:",
43-
"css-select": "^7.0.0"
43+
"css-select": "^7.0.0",
44+
"@standard-schema/spec": "^1.1.0",
45+
"hueful": "^0.8.1"
4446
},
4547
"devDependencies": {
4648
"@bomb.sh/web-platform-tests": "workspace:*"

‎packages/ui/src/dom.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { findElement, findElements, querySelector } from './css-select.ts';
44
import { asciiUppercase, asciiLowercase } from './ascii.ts';
55
import { NamedNodeMap } from './named-node-map.ts';
66
import { HTMLCollection } from './html-collection.ts';
7+
import { StyleDeclaration } from './style.ts';
78
import {
89
validateElementName,
910
validateElementNamespace,
@@ -476,6 +477,7 @@ export interface EventListener {
476477
export class Element extends Node {
477478
declare readonly ownerDocument: Document;
478479

480+
readonly style: StyleDeclaration;
479481
readonly localName: string;
480482
readonly nodeName: string;
481483
readonly namespaceURI: string | null;
@@ -490,6 +492,7 @@ export class Element extends Node {
490492
{ namespaceURI = HTML_NS, prefix = null }: Partial<ElementNamespace> = {},
491493
) {
492494
super(owner, notify);
495+
this.style = new StyleDeclaration(this.notify);
493496
this.localName = localName;
494497
this.namespaceURI = namespaceURI;
495498
this.prefix = prefix;

‎packages/ui/src/index.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,12 @@ export {
1010
HTMLTitleElement,
1111
HTMLUnknownElement,
1212
} from './dom.ts';
13+
14+
export type {
15+
ColorValue,
16+
BorderWidthValue,
17+
FlexDirectionValue,
18+
DisplayValue,
19+
LengthValue,
20+
BorderStyleValue,
21+
} from './style.ts';

0 commit comments

Comments
 (0)