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

Function find_inline_style_value

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

Find a property value in an element's inline `style` attribute (last declaration wins).

(style: &'a str, property: &str)

Source from the content-addressed store, hash-verified

121
122/// Find a property value in an element's inline `style` attribute (last declaration wins).
123fn find_inline_style_value<'a>(style: &'a str, property: &str) -> Option<&'a str> {
124 let mut input = cssparser::ParserInput::new(style);
125 let mut css_parser = cssparser::Parser::new(&mut input);
126 let mut declaration_parser = parser::CSSDeclarationListParser;
127 let declarations = cssparser::RuleBodyParser::new(&mut css_parser, &mut declaration_parser);
128 let mut found = None;
129 for (name, value) in declarations.flatten() {
130 if name.eq_ignore_ascii_case(property) {
131 found = Some(value);
132 }
133 }
134 found
135}
136
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.

Callers 1

start_elemMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected