1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
//! Inline `style="..."` parsing and serialization (v0.7.2).
//!
//! Build-time: `crate::document::build_element` calls
//! [`parse_inline_style`] on the `style` attribute (if present)
//! and pre-populates `el.style` with the resulting
//! camelCase-keyed properties. So `<div style="color: red">`
//! gives `el.style.color === 'red'` and
//! `<div style="font-size: 14px">` gives
//! `el.style.fontSize === '14px'`.
//!
//! Extract-time: [`crate::extract::extract_document`] walks the
//! style Object's property list, calls [`serialize_inline_style`]
//! to render it back to a kebab-case `style="..."` string, and
//! writes that into the dom-cat element's attribute list. So a
//! JS-side `el.style.color = 'blue'` shows up in the
//! post-eval dom-cat tree as `style="color: blue"`.
//!
//! Limitations (v0):
//!
//! - Property values are stored verbatim; no normalisation
//! (`'red'` vs `'#ff0000'` round-trip as-is).
//! - No vendor-prefix support (`WebkitTransform` /
//! `MozTransform` would map to `-webkit-transform` /
//! `-moz-transform` per spec; this module's `camel_to_kebab`
//! doesn't special-case the leading uppercase, so vendor
//! props end up as lowercase only).
//! - Single-colon split on the first `:`, so values containing
//! `:` (e.g. `background: url(http://...)`) are preserved
//! correctly by leaving everything after the first colon as
//! the value.
/// Parse a `style="..."` attribute value into camelCase-keyed
/// properties. Splits on `;`, then on the first `:`, trims, and
/// converts each kebab-case key into camelCase so JS dot-notation
/// (`el.style.fontSize`) works. Returns the properties in source
/// order; the caller is responsible for de-duplication (last-write
/// wins per the CSS cascade).
/// Serialize `properties` back to a kebab-case `style="..."`
/// string suitable for dom-cat's attribute list. Renders each
/// pair as `key: value` joined by `"; "`; returns an empty string
/// for an empty input so the caller can drop the `style`
/// attribute entirely.