Find a property value in an element's inline `style` attribute (last declaration wins).
(style: &'a str, property: &str)
| 121 | |
| 122 | /// Find a property value in an element's inline `style` attribute (last declaration wins). |
| 123 | fn 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. |