MCPcopy Create free account
hub / github.com/Stranger6667/css-inline / effective_dimension

Function effective_dimension

css-inline/src/html/serializer.rs:139–151  ·  view source on GitHub ↗

Pick the cascade-effective value between an inline `style` declaration and a stylesheet rule. Precedence (high to low): inline `!important`, stylesheet `!important`, inline, stylesheet.

(
    inline: Option<&'a str>,
    stylesheet: Option<&'a str>,
)

Source from the content-addressed store, hash-verified

137/// Pick the cascade-effective value between an inline `style` declaration and a stylesheet rule.
138/// Precedence (high to low): inline `!important`, stylesheet `!important`, inline, stylesheet.
139fn effective_dimension<'a>(
140 inline: Option<&'a str>,
141 stylesheet: Option<&'a str>,
142) -> Option<&'a str> {
143 let important = |v: &str| v.trim_end().ends_with("!important");
144 if inline.is_some_and(important) {
145 inline
146 } else if stylesheet.is_some_and(important) {
147 stylesheet
148 } else {
149 inline.or(stylesheet)
150 }
151}
152
153#[allow(clippy::too_many_arguments, clippy::fn_params_excessive_bools)]
154pub(crate) fn serialize_to<W: Write>(

Callers 1

start_elemMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected